Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Currency V BCD
Tue, Mar 25 2008 11:37 PMPermanent Link

Phil Read
Hi All,

I'm having rounding issues using Currency fields in DBISAM as I'm aware
I should be using BCD and then the Delphi / BCB Currency to use that
info. Is BCD 4 the best one to use or would BCD 2 be better where all
money amounts are rounded to their 2 decimal places in each record?

BCD sounds fine, but can I ask what would one use the Currency type for?
If I can't use currency in DBISAM for storing monetary amounts that I
want to multiply and divide and work out calculations of money?

Thanks for your time,

Phil.
Wed, Mar 26 2008 7:20 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Phil

> Is BCD 4 the best one to use or would BCD 2 be better where all money
> amounts are rounded to their 2 decimal places in each record?

There is no general rule - it depends on your particular needs, in each
situation.
For example, if you are storing invoices, you may nedd to store item prices
with 3 or even 4 decimal places, but the total values may be rounded to 2
decimal places. If you are dealing with multiple currencies and need to
store exchange rates, then you will need more than 4 decimal places, so a
Currency/BCD type will not be appropriate and you must be very careful with
the types, rounding, order of calculations, etc..


> BCD sounds fine, but can I ask what would one use the Currency type for?
> If I can't use currency in DBISAM for storing monetary amounts that I want
> to multiply and divide and work out calculations of money?

The types, routines, etc, used for fixed-point numbers are:
   DBISAM Columns : "BCD" type
   DBISAM SQL Type: NUMERIC
   Delphi Variables: "Currency" type
   Delphi persistent field type: TBCDField
   Access non-persistent fields: FieldByName(<fieldname>).AsCurrency

There is also a TCurrencyField type that can lead to some confusion, because
this is not an EXACT numeric type but a descendant of TFloatField. Values
stored using this field type are in fact "Float".

--
Fernando Dias




Image