(self)
| 1741 | @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; Error message too long") |
| 1742 | @requires_IEEE_754 |
| 1743 | def testRemainder(self): |
| 1744 | from fractions import Fraction |
| 1745 | |
| 1746 | def validate_spec(x, y, r): |
| 1747 | """ |
| 1748 | Check that r matches remainder(x, y) according to the IEEE 754 |
| 1749 | specification. Assumes that x, y and r are finite and y is nonzero. |
| 1750 | """ |
| 1751 | fx, fy, fr = Fraction(x), Fraction(y), Fraction(r) |
| 1752 | # r should not exceed y/2 in absolute value |
| 1753 | self.assertLessEqual(abs(fr), abs(fy/2)) |
| 1754 | # x - r should be an exact integer multiple of y |
| 1755 | n = (fx - fr) / fy |
| 1756 | self.assertEqual(n, int(n)) |
| 1757 | if abs(fr) == abs(fy/2): |
| 1758 | # If |r| == |y/2|, n should be even. |
| 1759 | self.assertEqual(n/2, int(n/2)) |
| 1760 | |
| 1761 | # triples (x, y, remainder(x, y)) in hexadecimal form. |
| 1762 | testcases = [ |
| 1763 | # Remainders modulo 1, showing the ties-to-even behaviour. |
| 1764 | '-4.0 1 -0.0', |
| 1765 | '-3.8 1 0.8', |
| 1766 | '-3.0 1 -0.0', |
| 1767 | '-2.8 1 -0.8', |
| 1768 | '-2.0 1 -0.0', |
| 1769 | '-1.8 1 0.8', |
| 1770 | '-1.0 1 -0.0', |
| 1771 | '-0.8 1 -0.8', |
| 1772 | '-0.0 1 -0.0', |
| 1773 | ' 0.0 1 0.0', |
| 1774 | ' 0.8 1 0.8', |
| 1775 | ' 1.0 1 0.0', |
| 1776 | ' 1.8 1 -0.8', |
| 1777 | ' 2.0 1 0.0', |
| 1778 | ' 2.8 1 0.8', |
| 1779 | ' 3.0 1 0.0', |
| 1780 | ' 3.8 1 -0.8', |
| 1781 | ' 4.0 1 0.0', |
| 1782 | |
| 1783 | # Reductions modulo 2*pi |
| 1784 | '0x0.0p+0 0x1.921fb54442d18p+2 0x0.0p+0', |
| 1785 | '0x1.921fb54442d18p+0 0x1.921fb54442d18p+2 0x1.921fb54442d18p+0', |
| 1786 | '0x1.921fb54442d17p+1 0x1.921fb54442d18p+2 0x1.921fb54442d17p+1', |
| 1787 | '0x1.921fb54442d18p+1 0x1.921fb54442d18p+2 0x1.921fb54442d18p+1', |
| 1788 | '0x1.921fb54442d19p+1 0x1.921fb54442d18p+2 -0x1.921fb54442d17p+1', |
| 1789 | '0x1.921fb54442d17p+2 0x1.921fb54442d18p+2 -0x0.0000000000001p+2', |
| 1790 | '0x1.921fb54442d18p+2 0x1.921fb54442d18p+2 0x0p0', |
| 1791 | '0x1.921fb54442d19p+2 0x1.921fb54442d18p+2 0x0.0000000000001p+2', |
| 1792 | '0x1.2d97c7f3321d1p+3 0x1.921fb54442d18p+2 0x1.921fb54442d14p+1', |
| 1793 | '0x1.2d97c7f3321d2p+3 0x1.921fb54442d18p+2 -0x1.921fb54442d18p+1', |
| 1794 | '0x1.2d97c7f3321d3p+3 0x1.921fb54442d18p+2 -0x1.921fb54442d14p+1', |
| 1795 | '0x1.921fb54442d17p+3 0x1.921fb54442d18p+2 -0x0.0000000000001p+3', |
| 1796 | '0x1.921fb54442d18p+3 0x1.921fb54442d18p+2 0x0p0', |
| 1797 | '0x1.921fb54442d19p+3 0x1.921fb54442d18p+2 0x0.0000000000001p+3', |
| 1798 | '0x1.f6a7a2955385dp+3 0x1.921fb54442d18p+2 0x1.921fb54442d14p+1', |
| 1799 | '0x1.f6a7a2955385ep+3 0x1.921fb54442d18p+2 0x1.921fb54442d18p+1', |
| 1800 | '0x1.f6a7a2955385fp+3 0x1.921fb54442d18p+2 -0x1.921fb54442d14p+1', |
nothing calls this directly
no test coverage detected