Subject RE: [firebird-support] Numeric(18,4) calculations
Author Helen Borrie
At 12:53 AM 25/05/2006, you wrote:

> >>So adjust your multiplication and division expressions accordingly,
> >>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)

select cast ((12.6789 * 67.5678) as numeric (18,4)) as result from rdb$database

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 ?