Subject | Re: [firebird-support] NUMERIC(18,6) calculation problem |
---|---|
Author | The Wogster |
Post date | 2006-02-24T11:51:30Z |
Luis Madaleno wrote:
fld1 is NUMERIC(18,6) 12 digits before the decimal 6 after
fld2 is NUMERIC(18,6) 12 digits before the decimal 6 after
fld3 is NUMERIC(18,12) 6 digits before the decimal 6 after
perhaps the solution is:
new.fld3 = CAST(CAST (new.fld1 as DOUBLE) * CAST (new.fld2 as DOUBLE) as
NUMERIC (18,6))
Now your doing the math as a double and then casting it back to NUMERIC.
W
> But it also fails using a CAST:What I see here is this:
>
> new.fld3 = CAST((new.fld1 * new.fld2) AS NUMERIC(18,6));
>
> What is the best field definition for currency values, with a precision
> of at least 6 digits?
>
> Regards,
>
> Luis
>
>
fld1 is NUMERIC(18,6) 12 digits before the decimal 6 after
fld2 is NUMERIC(18,6) 12 digits before the decimal 6 after
fld3 is NUMERIC(18,12) 6 digits before the decimal 6 after
perhaps the solution is:
new.fld3 = CAST(CAST (new.fld1 as DOUBLE) * CAST (new.fld2 as DOUBLE) as
NUMERIC (18,6))
Now your doing the math as a double and then casting it back to NUMERIC.
W