Subject Re: [ib-support] Automatic Conversion from Numeric to Integer
Author Helen Borrie
At 02:52 AM 08-11-02 +0100, you wrote:
>I have a variable in a SP like this
>declare variable Result Numeric(10,5);
>and in the body of the SP I do the following calculation
>Result=1/2;
>
>The result is always 0, But when I do
>Result=cast(1 as Numeric(10,5))/2
>the result is 0.5
>
>Exists a way to avoid the cast ? I'm using FB 1.0

Not really. Fb and IB 6+ are now compliant with the SQL standard, in that
integer /integer returns integer, by truncating.

What you *could* try is this:
Result=1/2.00000
should (I think) give you 0.50000

1.000000 / 2.000000 would give you an overflow error, so you would have to
cast that result...

On the whole, I think casting is safest.

heLen