WTF ?

Peter Corlett abuse at cabal.org.uk
Wed Jan 10 12:45:39 GMT 2007


On Wed, Jan 10, 2007 at 12:39:25PM +0000, Paul Orrock wrote:
[...]
> Can anyone explain why this is ? I get the correct (in my eyes) 1dp / 2dp
> result with 0.04 and 0.06 but 0.05 ends up to 14dp ?

Don't they teach this sort of thing in programming classes and textbooks any
more?

Most decimal numbers cannot be represented exactly as a floating-point
number. Once you perform a large number of calculations, the errors will
accumulate and soon show up.

Perl's DWIM cheats slightly to hide such errors in printed output, but it
will still show up if you push it hard enough.



More information about the london.pm mailing list