[fpc-pascal] Why this evaluates on "if" wrong ?

Daniël Mantione daniel.mantione at freepascal.org
Sun Oct 28 19:59:52 CET 2007



Op Sun, 28 Oct 2007, schreef L:

> > > If you do on a hand calculator:
> > > 
> > > 1/3
> > > 
> > > ... you will see:
> > > 
> > > 0.33333333333
> > > 
> > > If you multiply again with 3, you will see:
> > > 
> > > 0.99999999999
> > > 
> > > ... and not 1.00000000000.
> 
> 
> On my electronic/digital calculator I see '1'
> 
> It is a casio fx-300SA
> 
> Maybe $5 digital calculators are smarter than $3000 computers ;)

It isn't smarter, but it has more digits. Press the "pi" button and 
subtract the number you see in your display. That'll reveal how many 
digits your calculation uses.

Regarding the $3000 computer: An extended has 20 digits of precision. 
Make sure you round your output to 10 digits and you need to a very weird 
calcation until you can see a rounding difference :) 

Daniël


More information about the fpc-pascal mailing list