Op Sun, 28 Oct 2007, schreef Milan Marusinec:

> Hello folks,
> 
> This one looks pretty elementary, but to my big surprise
> it doesn't work as I would expect.
> 
> I'd like to ask FreePascal compiler creators, how can I safely
> evaluate double variables in case like this.
> 
> Sample program with comment is in attachement ...

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.

There is a similar issue here. The value "0.4" cannot be stored exactly in 
a computer, therefore it is rounded.

This behaviour normal and while annoying, it is simply how things work 
in the digital world, you will have to work around it.

Daniël
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to