mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #14521: Make result of float('nan') and float('-nan') more consistent across platforms. Further, don't rely on Py_HUGE_VAL for float('inf').
This commit is contained in:
parent
d68ac85e9a
commit
e383e82e04
5 changed files with 102 additions and 5 deletions
|
@ -870,6 +870,19 @@ class InfNanTest(unittest.TestCase):
|
|||
self.assertFalse(NAN.is_inf())
|
||||
self.assertFalse((0.).is_inf())
|
||||
|
||||
def test_inf_signs(self):
|
||||
self.assertEqual(copysign(1.0, float('inf')), 1.0)
|
||||
self.assertEqual(copysign(1.0, float('-inf')), -1.0)
|
||||
|
||||
@unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short',
|
||||
"applies only when using short float repr style")
|
||||
def test_nan_signs(self):
|
||||
# When using the dtoa.c code, the sign of float('nan') should
|
||||
# be predictable.
|
||||
self.assertEqual(copysign(1.0, float('nan')), 1.0)
|
||||
self.assertEqual(copysign(1.0, float('-nan')), -1.0)
|
||||
|
||||
|
||||
fromHex = float.fromhex
|
||||
toHex = float.hex
|
||||
class HexFloatTestCase(unittest.TestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue