Subject | RE: [firebird-support] Numeric(18,4) calculations |
---|---|
Author | Helen Borrie |
Post date | 2006-05-24T15:53:26Z |
At 12:53 AM 25/05/2006, you wrote:
yields 856.6854
(856.68537942 as numeric(18,8)
You could get an overflow on the left side of the decimal,
though. That is a trap with storing money as scale 4 numbers, esp.
in currencies with low-value units. Precision blows out at 18,
regardless of scale. For those currencies you'd need to be working
with double precision at some point[s]. Have you read Geoff Worboys'
article 'Working with Currency and Scaled Numeric Data Types' at
www.ibobjects.com/TechInfo.html ?
./hb
> >>So adjust your multiplication and division expressions accordingly,select cast ((12.6789 * 67.5678) as numeric (18,4)) as result from rdb$database
> >>using CAST or a rounding algorithm, according again to business
> >>requirements.
>
>Let's say your business requirements are for the result to be rounded to
>4 decimal places.
>
>Can you give an example statement which would not cause an overflow?
>
>(I too have this problem, and I'm not quite sure which value to cast
>where and when)
yields 856.6854
(856.68537942 as numeric(18,8)
You could get an overflow on the left side of the decimal,
though. That is a trap with storing money as scale 4 numbers, esp.
in currencies with low-value units. Precision blows out at 18,
regardless of scale. For those currencies you'd need to be working
with double precision at some point[s]. Have you read Geoff Worboys'
article 'Working with Currency and Scaled Numeric Data Types' at
www.ibobjects.com/TechInfo.html ?
./hb