import math
import random
+import platform
import sys
import unittest
import warnings
# PyFloat_Pack/Unpack*() API. See also gh-130317 and
# e.g. https://developercommunity.visualstudio.com/t/155064
signaling = 0
+ if platform.machine().startswith('parisc'):
+ # HP PA RISC uses 0 for quiet, see:
+ # https://en.wikipedia.org/wiki/NaN#Encoding
+ signaling = 1
quiet = int(not signaling)
if size == 8:
payload = random.randint(signaling, 0x7ffffffffffff)
import math
import operator
import unittest
+import platform
import struct
import sys
import weakref
# Check that packing produces a bit pattern representing a quiet NaN:
# all exponent bits and the msb of the fraction should all be 1.
+ if platform.machine().startswith('parisc'):
+ # HP PA RISC uses 0 for quiet, see:
+ # https://en.wikipedia.org/wiki/NaN#Encoding
+ expected = 0x7c
+ else:
+ expected = 0x7e
+
packed = struct.pack('<e', math.nan)
- self.assertEqual(packed[1] & 0x7e, 0x7e)
+ self.assertEqual(packed[1] & 0x7e, expected)
packed = struct.pack('<e', -math.nan)
- self.assertEqual(packed[1] & 0x7e, 0x7e)
+ self.assertEqual(packed[1] & 0x7e, expected)
# Checks for round-to-even behavior
format_bits_float__rounding_list = [