Subject Re: [firebird-support] division by zero in FB2.5
Author Alan J Davies
mmbtu=tons*:mmbtu_factor, /* factor is 8.54 supplied from another table

near the top of SP
select mmbtu*0.002
from paramfil
into mmbtu_factor,
tons are always <>0 by selection, so mmbtu cannot be 0

I come back to the same question - it works with the same data on 2.1
but not 2.5
Thanks
Alan J Davies
Aldis


On 24/10/2011 19:14, Jesus Garcia wrote:
> What is the value of mmbtu?
>
> Jesus Angel Garcia Zarco
> Cointec
> Correo Móvil
>
> El 24/10/2011, a las 17:18, Alan J Davies
> <Alan.Davies@...
> <mailto:Alan.Davies%40aldis-systems.co.uk>> escribió:
>
> > Hi, has there been a change in the way division is done since FB 2.1
> > I realise I may be asking this question in the wrong list, but here goes.
> > I have an SP which has been running since Feb 2009 every month with not
> > one failure. Moving this to FB 2.5 results in failure every time.
> > Basically all my routines are wrapped inside a coalesce statement such
> > as this:
> >
> > water_tons = iif(water_pc=0,0,coalesce(tons*water_pc/100,0)),
> > tons_water_tons = iif(water_pc=0,0.01,tons),
> > ash_tons = iif(ash_pc=0,0,coalesce(tons*ash_pc/100,0)),
> > tons_ash_tons = iif(ash_pc=0,0.01,tons),
> >
> > mmbtu_$ = iif(total_$=0 or tons<=1,0,coalesce(round(total_$/mmbtu,2),0)),
> >
> > Have I consistently got this wrong and have just been lucky or have I
> > coded this completely wrong and the divide an integer by zero happens
> > because the calculation order is different?
> > The error message is
> > Arithmetic overflow or division by zero has occurred
> > ......
> > The code attempted to divide an integer value by an integer divisor
> of zero.
> >
> > Any help or advice on defensive coding in a different way gratefully
> > accepted.
> >
> > Regards
> > Alan
> >
> > --
> > Alan J Davies
> > Aldis
> >
>
> [Non-text portions of this message have been removed]
>
>
>
> No virus found in this message.
> Checked by AVG - www.avg.com <http://www.avg.com>
> Version: 2012.0.1831 / Virus Database: 2092/4571 - Release Date: 10/24/11
>