diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-12-04 12:25:30 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-12-04 12:25:30 (GMT) |
commit | d2a9b20efaa15b0152856a545b0206af21d06c5e (patch) | |
tree | 7efc34a2bef5d875d674b11ab5078d12c325383a /Lib | |
parent | 7f4bc00d9f85f9328e020ddcab35ddd6f120d665 (diff) | |
download | cpython-d2a9b20efaa15b0152856a545b0206af21d06c5e.zip cpython-d2a9b20efaa15b0152856a545b0206af21d06c5e.tar.gz cpython-d2a9b20efaa15b0152856a545b0206af21d06c5e.tar.bz2 |
Issue #10596: Fix float.__mod__ to have the same behaviour as
float.__divmod__ with respect to signed zeros.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_float.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index 9bcd63d..ddf93bc 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -197,6 +197,26 @@ class GeneralFloatCases(unittest.TestCase): self.assertEqual((a, copysign(1.0, a)), (b, copysign(1.0, b))) @requires_IEEE_754 + def test_float_mod(self): + # Check behaviour of % operator for IEEE 754 special cases. + # In particular, check signs of zeros. + mod = operator.mod + + self.assertEqualAndEqualSign(mod(-1.0, 1.0), 0.0) + self.assertEqualAndEqualSign(mod(-1e-100, 1.0), 1.0) + self.assertEqualAndEqualSign(mod(-0.0, 1.0), 0.0) + self.assertEqualAndEqualSign(mod(0.0, 1.0), 0.0) + self.assertEqualAndEqualSign(mod(1e-100, 1.0), 1e-100) + self.assertEqualAndEqualSign(mod(1.0, 1.0), 0.0) + + self.assertEqualAndEqualSign(mod(-1.0, -1.0), -0.0) + self.assertEqualAndEqualSign(mod(-1e-100, -1.0), -1e-100) + self.assertEqualAndEqualSign(mod(-0.0, -1.0), -0.0) + self.assertEqualAndEqualSign(mod(0.0, -1.0), -0.0) + self.assertEqualAndEqualSign(mod(1e-100, -1.0), -1.0) + self.assertEqualAndEqualSign(mod(1.0, -1.0), -0.0) + + @requires_IEEE_754 def test_float_pow(self): # test builtin pow and ** operator for IEEE 754 special cases. # Special cases taken from section F.9.4.4 of the C99 specification |