Why does python break IEEE 754 for 1.0/0.0 and 0.0/0.0?
Grant Edwards
grante at visi.com
Thu Jul 14 18:09:19 EDT 2005
On 2005-07-14, Martin v. Löwis <martin at v.loewis.de> wrote:
>> 1/0 is defined by the standard as +Inf and 0/0 is NaN.
>
> I wonder why Tim hasn't protested here: I thought this was *not*
> the case. I thought IEEE 754 defined +Inf and NaN as only a possible
> outcome of these operations with other possible outcomes being
> exceptions...
The "exceptions" specified by the standard aren't required, but
it's "strongly recommended" that they be provided as options
for the programmer. If provided, I believe they are to be
resumable so that the user can determine what operation was
attempted on what operands and return a result if desired.
> In that case, Python would comply to IEEE 754 in this respect
My recollection is that returning Inf and NaN is to be the
default behavior, and a resumable exception is a recommended
option.
> (although in a different way than the C implementation on the
> same system).
I can't find my copy of the standard at the moment, though I
did just re-read Goldberg's 1991 discussion of the standard.
--
Grant Edwards grante Yow! My Aunt MAUREEN was
at a military advisor to IKE &
visi.com TINA TURNER!!
More information about the Python-list
mailing list