Hi,
Code snippet 1 and 2 convert an hex to float, but the SNaN is changed to QNaN automatically. It follows IEEE 754 behavior.
While Code snippet 3 converts an hex to double, and the SNaN keeps.
Is there any solution to keep SNaN float unchanged in Code snippet 1 and 2?
>>> cp = pointer(c_uint32(i))
>>> fp = cast(cp, POINTER(c_float))
>>> print(fp.contents.value) # nan
>>> print(struct.pack(">f", fp.contents.value).hex())
7fc00001
>>> f # nan
>>> hex(struct.unpack('<I', struct.pack('<f', f))[0])
'0x7fc00001'
>>> cp = pointer(c_uint64(i))
>>> fp = cast(cp, POINTER(c_double))
>>> print(fp.contents.value)
nan
>>> print(struct.pack(">d", fp.contents.value).hex())
7ff0000000000001
Thank you in advance!