Subject Re: [firebird-support] NUMERIC(18,6) calculation problem
Author The Wogster
Luis Madaleno wrote:
> But it also fails using a CAST:
>
> 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
>
>

What I see here is this:

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