Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Precision problem with BCD fields

292 views
Skip to first unread message

Jonathan J Quick

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
I'm having a problem with precision using BCD fields as follows:

In a Paradox database I have a BCD field defined with 6 digits of precision
after the decimal point.

In Database Desktop I can enter and view data using all 6 digits of
precision.

In my application program, the TTable object only reads 4 digits of
precision from the field.

In a test program using the DBGrid component, only 4 digits of precision
are read.

In Database Explorer, only 4 digits of precision are read.

Is there some obscure setting controlling the amount of precision Delphi
will use with BCD fields? In Control Panel/Regional Settings/Number of have
Number of Digits after the decimal point set to 9. In BDE
Administrator/System/Formats/Number I have DECIMALDIGITS set to 10. What
have I missed?

Tia,

JJ.

--
Email: jjq...@foxtrot.co.uk
Homepage: http://www.foxtrot.co.uk/

Bernd Ua

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
> What have I missed?

Delphi's Help file :

Select Help | Index, type in "TBCDField" and you'll read the
following :

>>>>>>from Delphi Help>>>>>>>>

Normally, BCD values are stored and manipulated in decimal
(base ten). However, Delphi does not have a native
binary-coded decimal type, so TBCDField uses the Currency
type to manipulate BCD values. Currency uses a binary (base
two) format.

Because TBCDField uses the Currency type to work with data
from BCD fields, TBCDField limits the precision of the BCD
values it can support to 4 decimal places and 20 significant
digits.

<<<<<<<<<<<

If you wan't more digits you can either switch to float or
derive a new TField-Descendant , which is capable of
handling BCD correctly. Although it's not very visual and
not very simple. There some libs from TurboPower, which
support calculating with BCD -Datatypes, perhaps they have
some DB-related Components, too. Might be worth to take a
look.
But be warned, a simple tax-calculation with BCD looks awful
due to the fact, that every operation has to be rebuild with
functions. It's one of the few places you'd like to have c++
like operator overloading.

nice hacking
Bernd

--
Bernd Ua - Software-Haus Brumund GmbH
u...@nospambrumund.de
// to reply, remove nospam from email adress :-)

Jonathan J Quick

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
Bernd Ua <u...@nospamBrumund.de> wrote in article
<74gqta$7r...@forums.borland.com>...
>
> [...invaluable advice snipped...]

Thanks for the info, you're a star. I have to say that Borland should not
have made such a mess of BCD support though...

0 new messages