Board index » delphi » Float Fields expanding the decimal places (19.99 becomes 19.899)

Float Fields expanding the decimal places (19.99 becomes 19.899)

I run Delphi 4.0 on a SQL Server 6.5 platform with version 5.01 of the BDE.
I have a field defined as a Numeric (8,4). Delphi defines it as Float.  When
I enter 19.99 into this field and save the record, the value stored in the
database is 19.8999.  I can't find any solution to this problem.  Any help
with this problem would be greatly appreciated.
 

Re:Float Fields expanding the decimal places (19.99 becomes 19.899)


do you use TUpdateSql object or execute sql statement dictly ?
in both case except in Tquery RequestLive without TUpdateSql you maybe will
have the same problem.

try put in bde in your alias BCD to true, take care because this setting
limit decimal to 4

Manuel

Quote
Phil <pmath...@subaru-isuzu.com> wrote in message

news:8266b8$9uc8@forums.borland.com...
Quote
> I run Delphi 4.0 on a SQL Server 6.5 platform with version 5.01 of the
BDE.
> I have a field defined as a Numeric (8,4). Delphi defines it as Float.
When
> I enter 19.99 into this field and save the record, the value stored in the
> database is 19.8999.  I can't find any solution to this problem.  Any help
> with this problem would be greatly appreciated.

Re:Float Fields expanding the decimal places (19.99 becomes 19.899)


Hi Phil!

On Thu, 2 Dec 1999 11:27:22 -0500, "Phil" <pmath...@subaru-isuzu.com>
wrote:

Quote
>I run Delphi 4.0 on a SQL Server 6.5 platform with version 5.01 of the BDE.
>I have a field defined as a Numeric (8,4). Delphi defines it as Float.  When
>I enter 19.99 into this field and save the record, the value stored in the
>database is 19.8999.  I can't find any solution to this problem.  Any help
>with this problem would be greatly appreciated.

It would be better that your field in MSSQL is declared as money
instead as numeric. In your particular example that would be the same
because money type is double-precision integer with 4 decimal places
and Delphi also see it as CurrencyField which is the same
representation in exe code so you will have no problems with that
approach.

tomi.

Re:Float Fields expanding the decimal places (19.99 becomes 19.899)


Money  has problems with round in SQL Server 6.5, I don't know with 7, but
it doesn't has problem
with Sybase

Manuel

Quote
Tomislav Kardas <nomail@sorry> wrote in message

news:3847125e.433928@forums.inprise.com...
Quote
> Hi Phil!

> On Thu, 2 Dec 1999 11:27:22 -0500, "Phil" <pmath...@subaru-isuzu.com>
> wrote:

> >I run Delphi 4.0 on a SQL Server 6.5 platform with version 5.01 of the
BDE.
> >I have a field defined as a Numeric (8,4). Delphi defines it as Float.
When
> >I enter 19.99 into this field and save the record, the value stored in
the
> >database is 19.8999.  I can't find any solution to this problem.  Any
help
> >with this problem would be greatly appreciated.

> It would be better that your field in MSSQL is declared as money
> instead as numeric. In your particular example that would be the same
> because money type is double-precision integer with 4 decimal places
> and Delphi also see it as CurrencyField which is the same
> representation in exe code so you will have no problems with that
> approach.

> tomi.

Re:Float Fields expanding the decimal places (19.99 becomes 19.899)


Hi manuel!

On Fri, 3 Dec 1999 12:24:14 -0300, "manuel parma" <mpa...@usa.net>
wrote:

Quote
>Money  has problems with round in SQL Server 6.5, I don't know with 7, but
>it doesn't has problem
>with Sybase

Can you elaborate more, what kind of problems? I use MS SQL 6.5 and
money datatype for my currencies, and it works OK, but I also ROUND
every operation to 2 digits.

tomi.

Re:Float Fields expanding the decimal places (19.99 becomes 19.899)


1) Ok Try create this table in sql 6.5

CREATE TABLE dbo.Table1 (
  Nro numeric(18, 4) NULL,
  Nr02 money NULL
)

2) Put BDE Alias in Enable BCD true

3) Put TQuery - TDataset TdataSource and TDBGrig into your form
TQuery.Sql = 'select * from Table1'
TQuery.RequestLive = True {this option is only to enable autoedit mode in
query}

3) Open tquery

edit each column with this value 1.0001
Post
in numeric column you get 1.0001
in money column you get 1.0000

try sybase and you will get 1.0001 in both columns

Manuel

Quote
Tomislav Kardas <nomail@sorry> wrote in message

news:3847f214.28706946@forums.inprise.com...
Quote
> Hi manuel!

> On Fri, 3 Dec 1999 12:24:14 -0300, "manuel parma" <mpa...@usa.net>
> wrote:

> >Money  has problems with round in SQL Server 6.5, I don't know with 7,
but
> >it doesn't has problem
> >with Sybase

> Can you elaborate more, what kind of problems? I use MS SQL 6.5 and
> money datatype for my currencies, and it works OK, but I also ROUND
> every operation to 2 digits.

> tomi.

Re:Float Fields expanding the decimal places (19.99 becomes 19.899)


Hi manuel!

On Mon, 6 Dec 1999 12:22:29 -0300, "manuel parma" <mpa...@usa.net>
wrote:

Quote
>1) Ok Try create this table in sql 6.5

>CREATE TABLE dbo.Table1 (
>  Nro numeric(18, 4) NULL,
>  Nr02 money NULL
>)

>2) Put BDE Alias in Enable BCD true

>3) Put TQuery - TDataset TdataSource and TDBGrig into your form
>TQuery.Sql = 'select * from Table1'
>TQuery.RequestLive = True {this option is only to enable autoedit mode in
>query}

>3) Open tquery

>edit each column with this value 1.0001
>Post
>in numeric column you get 1.0001
>in money column you get 1.0000

Well, I will not run into that problem cause in my apps such
currencies are never entered. In case if I need to enter more than 2
digits (like foreign currency rates) I use float data type on server.

I also do not use Numeric data types. I always use int, float & money.
And I have Enable BCD = false.

So I guess I will not run into problems with this.

Thank you for the info.

Other Threads