[Gambas-user] Bug in gb2 and gb3 in float

Benoît Minisini gambas at ...1...
Wed Dec 29 19:48:02 CET 2010


> > Hi!
> > 
> > I sent isolate program to test the error.
> > 
> > execute the program and follow this steps:
> > 
> > 1 - Click in "Cheque" button
> > 
> >      Using the mouse click in "Valor Cheque" textbox
> >      type 20000 and press tab key
> >      
> >      The Resta show 5123,56
> > 
> > 2 - click in button "Lançar"
> > 
> > 3 - Click in "Dinheiro" button
> > 
> >      Using the mouse click in "Valor Dinheiro" textbox
> >      type 5123,56 and press key tab
> > 
> > The error is.
> > 
> > Resta = 5123,56 (float)
> > mskVALOR = 5123,56
> > The breakpoint in 162
> > 
> > in debug window:
> >        ? vrresta  -> show(5123,56)
> >        ? tmpvalor -> show(5123,56)
> >        ? vrresta = tmpvalor ->show(FALSE)
> > 
> > PRESS Shift+F8 to continue to next line
> > 
> > Again in debug windo type:
> > ? vrResta
> > 9,094947017729E-13
> > 
> > ????????????
> > 
> > I'm use fc13, fc14 and ubuntu 10.10 in my computer for tests.
> > 
> > Reguards,
> > 
> > Wellington
> 
> I don't see a bug there, just a floating-point number rounding error.
> 
> You can see it by typing '?Frac(25123,56)'
> 
> Why? Because 0.56 cannot be written in binary, and floating point numbers
> are stored in binary.
> 
> Regards,

$ python -c "print 25123.56 - 25123 - 0.56"
1.30961907985e-12
$ gbx3 -e "25123.56 - 25123 - 0.56"
1,3096E-12

-- 
Benoît Minisini




More information about the User mailing list