|
23 | 23 | INF = float('inf') |
24 | 24 | NAN = float('nan') |
25 | 25 |
|
| 26 | +_testcapi = import_helper.import_module('_testcapi') |
| 27 | + |
26 | 28 | def iter_integer_formats(byteorders=byteorders): |
27 | 29 | for code in integer_codes: |
28 | 30 | for byteorder in byteorders: |
@@ -935,21 +937,17 @@ def test_half_float(self): |
935 | 937 |
|
936 | 938 | # Check that packing produces a bit pattern representing a quiet NaN: |
937 | 939 | # all exponent bits and the msb of the fraction should all be 1. |
938 | | - if platform.machine().startswith('parisc'): |
939 | | - # HP PA RISC uses 0 for quiet, see: |
| 940 | + if _testcapi.nan_encoding == 'parisc': |
| 941 | + # HP PA RISC and some MIPS CPUs use 0 for quiet, see: |
940 | 942 | # https://en.wikipedia.org/wiki/NaN#Encoding |
941 | 943 | expected = 0x7c |
942 | 944 | else: |
943 | 945 | expected = 0x7e |
944 | 946 |
|
945 | | - # Skip NaN encoding checks for MIPS because `math.nan` changes its value |
946 | | - # depending on toolchain settings. See: |
947 | | - # https://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html#index-mnan_003d2008 |
948 | | - if not platform.machine().startswith('mips'): |
949 | | - packed = struct.pack('<e', math.nan) |
950 | | - self.assertEqual(packed[1] & 0x7e, expected) |
951 | | - packed = struct.pack('<e', -math.nan) |
952 | | - self.assertEqual(packed[1] & 0x7e, expected) |
| 947 | + packed = struct.pack('<e', math.nan) |
| 948 | + self.assertEqual(packed[1] & 0x7e, expected) |
| 949 | + packed = struct.pack('<e', -math.nan) |
| 950 | + self.assertEqual(packed[1] & 0x7e, expected) |
953 | 951 |
|
954 | 952 | # Checks for round-to-even behavior |
955 | 953 | format_bits_float__rounding_list = [ |
|
0 commit comments