Subject Re: [firebird-support] Re: Numeric Calculation Error ?
Author Sibylle Koczian
At 11:42 14.01.2005, Dimitry Sibiryakov wrote:

>On 14 Jan 2005 at 9:49, kamen_lai wrote:
>
> >Sorry, I don't care about the figure after decimal point , but the
> >major problem is the integer part -230930 and 4984.
> >
> >1. The correct result should be positive but the first result is
> >netagive.
> >
> >2. -230930 is an error result
>
> Sorry, but if you substract two numbers from zero, result have to
>be negative. Probably, you forgot parentheses in the first case?

Would still give a negative result:

0.00 - (13060.45 * 9.031631 - 13060.45 * 8.65) =
0.00 - 13060.45 * (9.031631 - 8.65) = 0.00 - 13060.45 * 0.381631 < 0


> >> >> > select 0.00 - (13060.45*9.031631) - (13060.45*8.65) from
>
> Calculations of operations with the same priority is performed from
>left to right.
>
> >RDB$DATABASE
> >> >> >
> >> >> > the wrong result is -230930.057593950041
> >> >> > but
> >> >> >
> >> >> > select 0.00 + (13060.45*9.031631) - (13060.45*8.65) from
> >RDB$DATABASE
> >> >> >
> >> >> > get correct result is 4984.2725939500006
>--
> SY, Dimitry Sibiryakov.
>
>
>
>
>Yahoo! Groups Links
>
>
>
>

Dr. Sibylle Koczian
Universitaetsbibliothek, Abt. Naturwiss.
D-86135 Augsburg

Tel.: (0821) 598-2400, Fax : (0821) 598-2410
e-mail : Sibylle.Koczian@...-Augsburg.DE