diff options
author | Mark Dickinson <mdickinson@enthought.com> | 2021-08-20 10:40:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-20 10:40:11 (GMT) |
commit | 60b93d9e4922eeae25052bc15909d1f4152babde (patch) | |
tree | cc4b4b829ba5a2e8a5a4d8b97b99bea473d8f58c /Lib/test/test_float.py | |
parent | d26dbba9297adb59bc49a6583c647804ef56fc58 (diff) | |
download | cpython-60b93d9e4922eeae25052bc15909d1f4152babde.zip cpython-60b93d9e4922eeae25052bc15909d1f4152babde.tar.gz cpython-60b93d9e4922eeae25052bc15909d1f4152babde.tar.bz2 |
bpo-44954: Fix wrong result in float.fromhex corner case (GH-27834)
Diffstat (limited to 'Lib/test/test_float.py')
-rw-r--r-- | Lib/test/test_float.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index 38a17ce..29f7756 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -1468,6 +1468,20 @@ class HexFloatTestCase(unittest.TestCase): self.identical(fromHex('0X1.0000000000001fp0'), 1.0+2*EPS) self.identical(fromHex('0x1.00000000000020p0'), 1.0+2*EPS) + # Regression test for a corner-case bug reported in b.p.o. 44954 + self.identical(fromHex('0x.8p-1074'), 0.0) + self.identical(fromHex('0x.80p-1074'), 0.0) + self.identical(fromHex('0x.81p-1074'), TINY) + self.identical(fromHex('0x8p-1078'), 0.0) + self.identical(fromHex('0x8.0p-1078'), 0.0) + self.identical(fromHex('0x8.1p-1078'), TINY) + self.identical(fromHex('0x80p-1082'), 0.0) + self.identical(fromHex('0x81p-1082'), TINY) + self.identical(fromHex('.8p-1074'), 0.0) + self.identical(fromHex('8p-1078'), 0.0) + self.identical(fromHex('-.8p-1074'), -0.0) + self.identical(fromHex('+8p-1078'), 0.0) + def test_roundtrip(self): def roundtrip(x): return fromHex(toHex(x)) |