code not true?
Gordon McMillan
gmcm at hypernet.com
Sun Apr 23 09:11:20 EDT 2000
Michal Wallace wrote:
> On Sun, 23 Apr 2000, Kragen Sitaker wrote:
> > That said, it *is* just a speed issue --- there are representations
> > other than floating point, like the ordered-pair rational-number
> > representation, that give the right answer but are slower to work
> > with.
>
> But... Python is a scripting language.. It's okay to be slow.
It's not just a scripting language. Because numbers are
objects (not primitives), Python is already slow in doing math,
and the cumulative complaints about that are voluminous.
> From
> what I'm hearing, many people on this list shy away from floats simply
> because of the innacuracy.. Why don't we use the way that gets the
> right answer?
Some tech magazine columnist observed that there are 3
types of float users:
1) those who think it's easy, 'cause they're just like ints
2) those who think it's hard, 'cause they're nothing like ints
3) those who really know.
We've got exactly one 3 (and he's busy - having just bought a
CDROM with 660M of one-time pad <wink>). The transition
from 1 to 2 is hard (as witnessed by this thread). But once
you're a 2, it's not that hard to learn to use floats sanely.
The theoretically correct alternative is rationals. But they're
slow and use unpredictable amounts of memory. I think
Python should have BCD as an alternative. While slow, they're
predictable in memory use, and the mathematical
shortcomings they have are exactly those that a naive user
expects.
But I, despite being in category 2 for close to 20 years,
definitely don't want to be without floats.
- Gordon
More information about the Python-list
mailing list