diff -r d2fbefb1c818 Doc/library/math.rst --- a/Doc/library/math.rst Wed Jan 07 11:42:38 2015 -0600 +++ b/Doc/library/math.rst Wed Jan 07 18:42:15 2015 +0000 @@ -382,6 +382,14 @@ The mathematical constant e = 2.718281..., to available precision. +.. data:: inf + + A floating-point representation of positive infinity. (For negative + infinity, use ``-math.inf``). + +.. data:: nan + + A floating-point NaN. Equivalent to the output of ``float('nan')``. .. impl-detail:: diff -r d2fbefb1c818 Lib/test/test_math.py --- a/Lib/test/test_math.py Wed Jan 07 11:42:38 2015 -0600 +++ b/Lib/test/test_math.py Wed Jan 07 18:42:15 2015 +0000 @@ -983,6 +983,24 @@ self.assertFalse(math.isinf(0.)) self.assertFalse(math.isinf(1.)) + @requires_IEEE_754 + def test_nan_constant(self): + self.assertTrue(math.isnan(math.nan)) + # Check that float('nan') and math.nan give the same bit + # pattern. + float_nan = float('nan') + math_nan = math.nan + float_nan_bits = struct.unpack('