[fpc-pascal] Re: Why this evaluates on "if" wrong ? (GMP)
Vinzent Hoefler
JeLlyFish.software at gmx.net
Wed Oct 31 08:35:29 CET 2007
On Tuesday 30 October 2007 17:31, Inga Petuhhov wrote:
> A copy-paste from Python Shell:
> >>> a = 1
> >>> a
>
> 1
>
> >>> a = a + 0.4
> >>> a
>
> 1.3999999999999999
>
> >>> a = a - 0.4
> >>> a
>
> 0.99999999999999989
>
> >>> a == 1
>
> False
Or a bit more simple (and for some maybe even more surprising):
>>> 1.0 == 0.4 - 0.4 + 1.0
True
>>> 1.0 == 1.0 + 0.4 - 0.4
False
Floating points are not "real"s. Even simple commutative laws don't
hold.
Vinzent.
More information about the fpc-pascal
mailing list