Subject Re: [firebird-support] About UDF's problem
Author Bogusław Brandys
Helen Borrie wrote:
> At 09:06 AM 15/08/2005 +0800, you wrote:
>
>>Thanks.
>>But a new problem found.
>>Cast (Value1 as numeric(9,2)),Value1= 13.275,reuslt is 13.27;
>>Cast (Value2 as numeric(9,2)),Value2= 13.228,reuslt is 13.23;
>>what is the rule to round?
>
>
> It uses banker's rounding. But you get different results to what I get.
>
> select
> cast(13.275 as numeric(9,2)) as result from rdb$database
> returns 13.28
>
> select
> cast(13.228 as numeric(9,2)) as result from rdb$database
>
> returns 13.23

Related question:
I always store money values in field decimal(18,4),bacause I found it
good for tax computation.
Is this correct way for any currency limited to 1/100 like
1$=100c,1PLN=100gr etc. ?

Look at example below:

x=2.22 - 7%TAX=2.0747[663..]
cast(x as decimal(18,2))= 2.07 not 2.08
because for example 2.0747[663..]$ =~ 207.48c and it is rounded to 207c

Is my assumption correct ?

Regards
Boguslaw Brandys