possible bug in 1.5.1

Tim Peters tim_one at email.msn.com
Sun Apr 25 15:00:03 EDT 1999


[Tim]
> ...
> What you can do is save away the attached as (e.g.) ieee.py, then
> in your code do
>
>    from ieee import PINF  # positive infinity, if it exists

Oops -- the attachment got lost due to a rounding error <wink>.  Here:

def _make_inf():
    x = 2.0
    x2 = x * x
    i = 0
    while i < 100 and x != x2:
        x = x2
        x2 = x * x
        i = i + 1
    if x != x2:
        raise ValueError("This machine's floats go on forever!")
    return x

PINF = _make_inf()
MINF = -PINF
NAN = PINF - PINF
if 1.0 + NAN == 1.0:
    raise ValueError("This machine doesn't have NaNs, "
                     "'overflows' to a finite number, "
                     "or is 754-conformant but is using "
                     "a goofy rounding mode.")
PZERO = 0.0
MZERO = -PZERO






More information about the Python-list mailing list