[New-bugs-announce] [issue6675] inf == inf (wrong IEEE 754 behaviour)

D Hardy report at bugs.python.org
Mon Aug 10 15:44:25 CEST 2009

New submission from D Hardy <diggory.hardy at gmail.com>:

Currently python evaluates infinity as equal to itself in my tests (2.6.2 and 3.0.1+
from ubuntu). I'm not entirely sure whether the behaviour of 'inf == inf' is specified
by IEEE 754, but it leads to results like:

>>> 1e400
>>> 1e400 == 1e500

And hence unittests which use tests like

if not (math.fabs(value1 - value2) <= 0.00000001 *

don't always fail when they should (when a value is inf).

This is a specific example (and probably not the recommended way of testing
values in any case), but I think "inf != inf" is generally considered the correct
behaviour. (Although maybe this is left over from the PEP 42 / PEP 754 mess; I
wasn't able to find the current status of implementing IEEE 754 behaviour in

components: None
messages: 91443
nosy: Cyborg16
severity: normal
status: open
title: inf == inf (wrong IEEE 754 behaviour)
type: behavior
versions: Python 2.6, Python 3.0

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list