mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #10596: Fix float.__mod__ to have the same behaviour as
float.__divmod__ with respect to signed zeros.
This commit is contained in:
parent
7f4bc00d9f
commit
d2a9b20efa
3 changed files with 38 additions and 4 deletions
|
@ -196,6 +196,26 @@ class GeneralFloatCases(unittest.TestCase):
|
|||
# distingishes -0.0 and 0.0.
|
||||
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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue