Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Rounding and currency types
Sun, Apr 4 2010 9:33 PMPermanent Link

Stephen Barker

Hi,

I was under the impression that currency fields automatically rounded the values to 2dp.

However, when I apply a 20% margin to a cost price and then multiply by a large quantity (10000) I get an unexpected result:

cost: ftcurrency value=0.74
sell: ftcurrency value=0.74+20%=0.888, but shows in dbsys as 0.89
quantity: ftfloat value=10000

selecting sell*quantity gives $8880.00 instead of $8900.00

Does this mean I have to round every calculation before storing into a currency field?


(DBISAM 4, Delphi 2007)

Steve
Sun, Apr 4 2010 10:52 PMPermanent Link

Raul

Team Elevate Team Elevate


The currency in DBISAM is actually a float (and thus not really a currency type) and you might be better off using BCD.

Manual entry here : http://www.elevatesoft.com/manual?action=viewtopic&id=dbisam4&product=r&version=2007&topic=Data_Types_NULL_Support

Look under Currency section, including the warning there and BCD suggestion.

Raul
Mon, Apr 5 2010 9:37 PMPermanent Link

Stephen Barker

Raul wrote:


The currency in DBISAM is actually a float (and thus not really a currency type) and you might be better off using BCD.

Manual entry here : http://www.elevatesoft.com/manual?action=viewtopic&id=dbisam4&product=r&version=2007&topic=Data_Types_NULL_Support

Look under Currency section, including the warning there and BCD suggestion.

Raul

Thanks Raul - I've been using DBISAM for many years but never realised that. I will now force rounding of all values prior to saving.

Do most people use BCD for monetary values? It seems the storage overhead is quite a bit more, but are there any other issues?


Steve
Tue, Apr 6 2010 2:33 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Stephen,

<< Do most people use BCD for monetary values? It seems the storage overhead
is quite a bit more, but are there any other issues? >>

No, the only issue is the storage size.  FYI, ElevateDB only uses 8 bytes
per DECIMAL/NUMERIC (BCD) value, so it corrects the storage size issue.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image