[Baypiggies] Eric Raymond likes Python
Aahz
aahz at pythoncraft.com
Mon Sep 7 02:30:59 CEST 2009
On Sun, Sep 06, 2009, Delbert Franz wrote:
>
> The complaint about 1.1 printing as 1.10...01, is just plain lame!
> When I ask for a variable to be printed without a format given,
> I want all of what the variable contains. The protester needs a
> simple lesson in floating point arithmetic. Of course too many
> people in software know practically nothing of floating point and
> expect the computer to behave like the "real number" system. Simple
> answer: it does not and never will:) Get a life and print with a
> format that cuts off the unavoidable floating-point noise! If it
> helps any, gfortran does the same thing and I suspect any other
> Fortran implementation worth anything would do the same thing. I
> suspect many developers were never taught much about floating point
> or if they were, they have forgotten about it. Being a "number
> cruncher" requires a nearly constant awareness of the various pitfalls
> of ignoring the differences between floating-point arithmetic and
> real-number system arithmetic.
Note that Python does have an answer: the decimal module
Warning: just because you're doing decimal arithmetic does not mean you
can avoid awareness of floating point issues -- you are still doing
floating point with decimals, and all it saves you from is a few rounding
issues.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"Look, it's your affair if you want to play with five people, but don't
go calling it doubles." --John Cleese anticipates Usenet
More information about the Baypiggies
mailing list