Board index » delphi » rounding error in a NUMERIC field/MS SQL Server, Delphi5

rounding error in a NUMERIC field/MS SQL Server, Delphi5

I have MSSQL7, Delphi 5 and a NUMERIC (18,8) field. If I insert 12.12 into
this field with Borland SQL Explorer, 12.19999 results. If I turn on the
Enable BCD switch in the BDE Administrator for this alias, the rounding
error solves but only 4 decimal digits can be entered after the decimal
point, any other number is rounded, for example: 1.2345678 results in
1.2346!

What is your advice? To update BDE , update Delphi, update MSSQL, or to
forget Delphi and/or MS?

Any reply...

Thanks: Milan

 

Re:rounding error in a NUMERIC field/MS SQL Server, Delphi5


TFloatField has a precision of 15 digits.
TBCDField has a precision of 20 digits, but with only 4 decimal digits (based
on the Currency datatype in Delphi).

If you want to enter/read numbers with a higher precision, you'll have to use
casts on the server (sql) side (to read/write strings instead of numbers).
Anyway, you will have trouble doing any manipulation on those numbers within
Delphi, and should get an high-precision math library. You may also have
better luck with MSSQL-specific components.

Eric Grange

Other Threads