str smarter than round?
Michael Chermside
mcherm at destiny.com
Fri Jun 15 14:36:21 EDT 2001
Attention Tim:
I looked over the new appendix and have one tiny edit to suggest.
Original paragraph:
Note that this is in the very nature of binary floating-point: this is not a bug in Python, it is not a bug in your code either, and you'll see the same kind of thing in all languages that support your hardware's floating-point arithmetic.
My proposed modification:
Note that this is in the very nature of binary floating-point: this is not a bug in Python, it is not a bug in your code either, and you'll see the same kind of thing in all languages that support your hardware's floating-point arithmetic, although
some languages may not <i>display</i> the difference.
Reason for proposed modification:
Nieve readers are likely to read this and say, "hey... I've worked with <language X>,
before and never saw 0.1 == 0.10000000000000001. This manual obviously doesn't
know about <language X>." It is useful to explain that the difference between
Python and <language X> is not that Python can only approximate floating point
numbers, but that Python is HONEST about it.
Possible alternative wording:
...languages that support your hardware's floating-point arithmetic. Unlike Python,
some languages round the value off before displaying it, but the actual value is
still a binary approximation.
I prefer the first wording, but pick your favorite and go with it. And I have to
say, this is a very good job of addressing a perennial point of confusion.
-- Michael Chermside
More information about the Python-list
mailing list