Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions Lib/test/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,10 +942,15 @@ def test_half_float(self):
else:
expected = 0x7e

packed = struct.pack('<e', math.nan)
self.assertEqual(packed[1] & 0x7e, expected)
packed = struct.pack('<e', -math.nan)
self.assertEqual(packed[1] & 0x7e, expected)
# Skip NaN encoding checks for MIPS because `math.nan` changes its value
# depending on toolchain settings. See:
# https://en.wikipedia.org/wiki/NaN#Encoding
Comment thread
skirpichev marked this conversation as resolved.
Outdated
# https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/MIPS-Options.html#index-mnan_003d2008
Comment thread
skirpichev marked this conversation as resolved.
Outdated
if not platform.machine().startswith('mips'):
packed = struct.pack('<e', math.nan)
self.assertEqual(packed[1] & 0x7e, expected)
packed = struct.pack('<e', -math.nan)
self.assertEqual(packed[1] & 0x7e, expected)

# Checks for round-to-even behavior
format_bits_float__rounding_list = [
Expand Down
Loading