G
Grant Edwards
I've read over and over that Python leaves floating point
issues up to the underlying platform.
This seems to be largely true, but not always. My underlying
platform (IA32 Linux) correctly handles 1.0/0.0 and 0.0/0.0
according to the IEEE 754 standard, but Python goes out of its
way to do the wrong thing.
1/0 is defined by the standard as +Inf and 0/0 is NaN.
That's what my platform does for programs written in C. Python
apparently checks for division by zero and throws and exception
rather than returning the correct value calculated by the
underlying platform.
Is there any way to get Python to return the correct results
for those operations rather than raising an exception?
There's no way to "resume" from the exception and return a
value from an exception handler, right? [This is the other
option allowed by the IEEE 754 standard.]
issues up to the underlying platform.
This seems to be largely true, but not always. My underlying
platform (IA32 Linux) correctly handles 1.0/0.0 and 0.0/0.0
according to the IEEE 754 standard, but Python goes out of its
way to do the wrong thing.
1/0 is defined by the standard as +Inf and 0/0 is NaN.
That's what my platform does for programs written in C. Python
apparently checks for division by zero and throws and exception
rather than returning the correct value calculated by the
underlying platform.
Is there any way to get Python to return the correct results
for those operations rather than raising an exception?
There's no way to "resume" from the exception and return a
value from an exception handler, right? [This is the other
option allowed by the IEEE 754 standard.]