[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Floating point and precision loss - a bug?
- From: David Kastrup <dak@...>
- Date: Fri, 18 May 2007 17:58:25 +0200
Luís Santos <firstname.lastname@example.org> writes:
> Hi folks,
> I have found a disturbing behaviour in the VM regarding floating point
> n = 1000.2
> print(n - 1000)
> -- result: 0.20000000000005
> Is it a bug in the 5.1.2 release?
No. 1000.2 has no exact representation in base 2 floating point
For that reason, financial calculations should be done in units of
cents or decicents, not dollars (insert your appropriate local