Skip to content

Commit

Permalink
[3.12] gh-123811: test that round() can return signed zero (GH-123829) (
Browse files Browse the repository at this point in the history
#123939)

gh-123811: test that round() can return signed zero (GH-123829)
(cherry picked from commit d2b9b6f)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
  • Loading branch information
3 people committed Sep 11, 2024
1 parent ec119dc commit 8ca75ee
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Lib/test/test_float.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ def test_short_repr(self):
self.assertEqual(repr(float(negs)), str(float(negs)))

@support.requires_IEEE_754
class RoundTestCase(unittest.TestCase):
class RoundTestCase(unittest.TestCase, FloatsAreIdenticalMixin):

def test_inf_nan(self):
self.assertRaises(OverflowError, round, INF)
Expand Down Expand Up @@ -859,10 +859,10 @@ def test_large_n(self):

def test_small_n(self):
for n in [-308, -309, -400, 1-2**31, -2**31, -2**31-1, -2**100]:
self.assertEqual(round(123.456, n), 0.0)
self.assertEqual(round(-123.456, n), -0.0)
self.assertEqual(round(1e300, n), 0.0)
self.assertEqual(round(1e-320, n), 0.0)
self.assertFloatsAreIdentical(round(123.456, n), 0.0)
self.assertFloatsAreIdentical(round(-123.456, n), -0.0)
self.assertFloatsAreIdentical(round(1e300, n), 0.0)
self.assertFloatsAreIdentical(round(1e-320, n), 0.0)

def test_overflow(self):
self.assertRaises(OverflowError, round, 1.6e308, -308)
Expand Down

0 comments on commit 8ca75ee

Please sign in to comment.