Why isn't Python king of the hill?
grante at visi.com
Sat Jun 2 19:13:49 CEST 2001
On Sat, 2 Jun 2001 16:49:58 +0000 (UTC), E. Mark Ping <emarkp at CSUA.Berkeley.EDU> wrote:
>>I know that it is. But when you start depending on that fact,
>That's silly and just plain wrong. You should depend on understanding
>how FP works. And in this case, 1.0 + 2.0 == 3.0 every time on every
>platform that I've run into--I don't know that because I just happened
>to try it out, but rather I know how the FP works on those platforms
>and know that it is correct.
So do I. But every time I've seen an application _depend_ on
exact representations, its caused problems. Perhaps the FP
code you've seen was better, but in my experience code that
depends on exact represention has caused problems.
>>>> should always treat floating point operations as if there are
>>>> small random numbers being thrown in at every step. So you
>>>I think this is exactly what Kahan describes as one of the
>>>widespread (and false) myths about floating point.
>>Of course it is not true. But if you pretend it is, you've got
>>a much better chance of producing working code.
>You should definitely read Pete Becker's articles in the June, July
>and October 2000 issues of The C/C++ Users Journal. He explains why
>you're statement is insufficient and incorrect. For instance, two
>very large numbers might really be the same, but be off by a bit.
Huh? They're the same, but they're not the same?
>Checking the difference of the values will yield another large number,
>and a method like "IsCloseTo" will incorrectly fail.
How can it fail? Either A is within X% of B or it isn't.
What's the problem?
>Really, floating point arithmetic has well-defined semantics; guessing
>and treating them as if they have random components is the lazy and
>error-prone way to use them.
I'm not guessing. I know how IEEE floating point works and
have implimented various parts of it over the years. The
applications programmers I've dealt with would have been far,
far better off if they never depended on exact representation.
I'm sure you hang out with a much brighter crowd than I.
Grant Edwards grante Yow! Did I say I was a
at sardine? Or a bus???
More information about the Python-list