Subject | Re: [ib-support] what is the best type for storing currency fields? |
---|---|
Author | David K. Trudgett |
Post date | 2002-02-12T23:05:42Z |
On Tuesday 2002-02-12 at 09:54:28 -0300, Marcelo Miorelli wrote:
cautious about rounding and precision. If you try to store a value
that has more significant places than a DOUBLE supports, your value
will be rounded to the maximum number of significant digits (since you
have been using DOUBLE PRECISION for currency, you should know what
that is better than I ;-) -- should be around 15 decimal digits).
Furthermore, certain mathematical and arithmetical operations may
produce inexact results. This is not usually acceptable in currency
values.
If you use INT64 (NUMERIC(18,0) for instance), you don't have to worry
about those problems, except that one obviously can't store a value
that contains 19 decimal digits or more! One problem with INT64,
though, is that not all client-side software can handle it properly.
You just need to do some testing to make sure that isn't a problem for
you.
David Trudgett
> Hello folks,If you use DOUBLE PRECISION for currency values you have to be very
> I know this question might have been raised here a couple of times, still I
> dont remember, and as long as I work with Interbase, since 1997, I am using
> the double precision. Now I saw some messages telling about numeric(15,2),
> so can someone tell me if I might be right, or it would be better to use
> this numeric field intead.
cautious about rounding and precision. If you try to store a value
that has more significant places than a DOUBLE supports, your value
will be rounded to the maximum number of significant digits (since you
have been using DOUBLE PRECISION for currency, you should know what
that is better than I ;-) -- should be around 15 decimal digits).
Furthermore, certain mathematical and arithmetical operations may
produce inexact results. This is not usually acceptable in currency
values.
If you use INT64 (NUMERIC(18,0) for instance), you don't have to worry
about those problems, except that one obviously can't store a value
that contains 19 decimal digits or more! One problem with INT64,
though, is that not all client-side software can handle it properly.
You just need to do some testing to make sure that isn't a problem for
you.
David Trudgett