Subject Re: [firebird-support] Currency / money Helen Borrie 2007-08-14T22:38:24Z
At 02:05 AM 15/08/2007, you wrote:
>Hi,
>
>Going from Paradox to FireBird I need to convert the \$-fieldtype
>(money) to a FireBird fieldtype. Poul's article on ibphonix recomend
>numeric(18,3) and others numeric(18,4), so I'm a bit puzzled about
>this.
>
>I have to support two digit (like cents),

Numeric(18,2) is fine, if you don't need 3 or four places of
scale. However, Poul has probably recommended a scale of 3 or 4 to
mitigate the loss of precision that occurs with integer division.

>so it's mostly division I'm a
>bit concerned about (e.g. 50.47 divided by 3, should be 16.82 (shown
>as) and not 16.823 or 16.8233).

With fixed decimal types (numeric and decimal) the scales of the
operands accumulate in the result. Adding the scales of the operands
will tell you what the scale of the result will be. An integer is a
numeric with a scale of zero.

So:

50.47 / 3 will give 16.82
50.47 / 3.0 will give 16.823
50.47 / 3.00 will give 16.8233

and so on, until you run out of precision and get an overflow.

Note also that the result of integer/integer gives integer, so 10/3
gives 3 and 1/3 gives zero.

>What do you all recomend?

You might like to read the following article:

http://www.ibobjects.com/docs/TI_Numerics.rtf

./heLen