Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread currency date value with 8 d.p.
Fri, Dec 2 2016 8:15 AMPermanent Link

kamran

Hi

So what is the recommended way to handle a currency rate which has up to 8 decimal places?

EDB has  "Decimal" var type  which has up to a scale of 4.

Any ideas for what variable type that should be used that ensure accuracy as far as possible?

Thanks

Kamran
Fri, Dec 2 2016 8:16 AMPermanent Link

kamran

sorry a typo: I mean rate *not* date

kamran wrote:

Hi

So what is the recommended way to handle a currency rate which has up to 8 decimal places?

EDB has  "Decimal" var type  which has up to a scale of 4.

Any ideas for what variable type that should be used that ensure accuracy as far as possible?

Thanks

Kamran
Fri, Dec 2 2016 8:27 AMPermanent Link

Matthew Jones

kamran wrote:

> Any ideas for what variable type that should be used that ensure accuracy as far as possible?

Me, I've found that the easiest way to handle things is by using "pence" or "cents" or whatever the relevant part is called. Simple old integers. This does of course depend on the maximum value that you will ever handle, but 64 bit int should give you a lot. If not, then keep them separately.

You might also have to consider things like rounding, where you deal in tenths of a cent, but that is usually on a per action basis and not stored.

Maybe other options exist, but never use anything "float".

--

Matthew Jones
Fri, Dec 2 2016 1:09 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<< So what is the recommended way to handle a currency rate which has up to 8 decimal places? >>

Your two options are: use a large int, like Matthew indicated, or use a float/double.  The float/double still has the possibility of floating-point representation issues, whereas the large int involves a bit more work in terms of displaying values.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Dec 2 2016 1:47 PMPermanent Link

kamran

Matthew and Tim * Thank you *

Tim Young [Elevate Software] wrote:


<< So what is the recommended way to handle a currency rate which has up to 8 decimal places? >>

Your two options are: use a large int, like Matthew indicated, or use a float/double.  The float/double still has the possibility of floating-point representation issues, whereas the large int involves a bit more work in terms of displaying values.

Tim Young
Elevate Software
www.elevatesoft.com
Image