(self)
| 2874 | self.assertEqual(math.fma(a - 1.0, a + 1.0, 1.0), a*a) |
| 2875 | |
| 2876 | def test_random(self): |
| 2877 | # A collection of randomly generated inputs for which the naive FMA |
| 2878 | # (with two rounds) gives a different result from a singly-rounded FMA. |
| 2879 | |
| 2880 | # tuples (a, b, c, expected) |
| 2881 | test_values = [ |
| 2882 | ('0x1.694adde428b44p-1', '0x1.371b0d64caed7p-1', |
| 2883 | '0x1.f347e7b8deab8p-4', '0x1.19f10da56c8adp-1'), |
| 2884 | ('0x1.605401ccc6ad6p-2', '0x1.ce3a40bf56640p-2', |
| 2885 | '0x1.96e3bf7bf2e20p-2', '0x1.1af6d8aa83101p-1'), |
| 2886 | ('0x1.e5abd653a67d4p-2', '0x1.a2e400209b3e6p-1', |
| 2887 | '0x1.a90051422ce13p-1', '0x1.37d68cc8c0fbbp+0'), |
| 2888 | ('0x1.f94e8efd54700p-2', '0x1.123065c812cebp-1', |
| 2889 | '0x1.458f86fb6ccd0p-1', '0x1.ccdcee26a3ff3p-1'), |
| 2890 | ('0x1.bd926f1eedc96p-1', '0x1.eee9ca68c5740p-1', |
| 2891 | '0x1.960c703eb3298p-2', '0x1.3cdcfb4fdb007p+0'), |
| 2892 | ('0x1.27348350fbccdp-1', '0x1.3b073914a53f1p-1', |
| 2893 | '0x1.e300da5c2b4cbp-1', '0x1.4c51e9a3c4e29p+0'), |
| 2894 | ('0x1.2774f00b3497bp-1', '0x1.7038ec336bff0p-2', |
| 2895 | '0x1.2f6f2ccc3576bp-1', '0x1.99ad9f9c2688bp-1'), |
| 2896 | ('0x1.51d5a99300e5cp-1', '0x1.5cd74abd445a1p-1', |
| 2897 | '0x1.8880ab0bbe530p-1', '0x1.3756f96b91129p+0'), |
| 2898 | ('0x1.73cb965b821b8p-2', '0x1.218fd3d8d5371p-1', |
| 2899 | '0x1.d1ea966a1f758p-2', '0x1.5217b8fd90119p-1'), |
| 2900 | ('0x1.4aa98e890b046p-1', '0x1.954d85dff1041p-1', |
| 2901 | '0x1.122b59317ebdfp-1', '0x1.0bf644b340cc5p+0'), |
| 2902 | ('0x1.e28f29e44750fp-1', '0x1.4bcc4fdcd18fep-1', |
| 2903 | '0x1.fd47f81298259p-1', '0x1.9b000afbc9995p+0'), |
| 2904 | ('0x1.d2e850717fe78p-3', '0x1.1dd7531c303afp-1', |
| 2905 | '0x1.e0869746a2fc2p-2', '0x1.316df6eb26439p-1'), |
| 2906 | ('0x1.cf89c75ee6fbap-2', '0x1.b23decdc66825p-1', |
| 2907 | '0x1.3d1fe76ac6168p-1', '0x1.00d8ea4c12abbp+0'), |
| 2908 | ('0x1.3265ae6f05572p-2', '0x1.16d7ec285f7a2p-1', |
| 2909 | '0x1.0b8405b3827fbp-1', '0x1.5ef33c118a001p-1'), |
| 2910 | ('0x1.c4d1bf55ec1a5p-1', '0x1.bc59618459e12p-2', |
| 2911 | '0x1.ce5b73dc1773dp-1', '0x1.496cf6164f99bp+0'), |
| 2912 | ('0x1.d350026ac3946p-1', '0x1.9a234e149a68cp-2', |
| 2913 | '0x1.f5467b1911fd6p-2', '0x1.b5cee3225caa5p-1'), |
| 2914 | ] |
| 2915 | for a_hex, b_hex, c_hex, expected_hex in test_values: |
| 2916 | with self.subTest(a_hex=a_hex, b_hex=b_hex, c_hex=c_hex, |
| 2917 | expected_hex=expected_hex): |
| 2918 | a = float.fromhex(a_hex) |
| 2919 | b = float.fromhex(b_hex) |
| 2920 | c = float.fromhex(c_hex) |
| 2921 | expected = float.fromhex(expected_hex) |
| 2922 | self.assertEqual(math.fma(a, b, c), expected) |
| 2923 | self.assertEqual(math.fma(b, a, c), expected) |
| 2924 | |
| 2925 | # Custom assertions. |
| 2926 | def assertIsNaN(self, value): |
nothing calls this directly
no test coverage detected