Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Open
Description
Bug report
Bug description:
importstructf=struct.unpack(">d",bytes.fromhex("7FF0000000080001"))[0]print(f)# nanf2=struct.unpack(">f",struct.pack(">f",f))[0]print(f2)# inf
Repeating this withFFF0000000080001 you'll seenan turn into-inf.
This only happens in Python 3.14+ (not 3.13). I'm pretty sure that this fix is causing it:#130317
Preserving the signaling/quieting bit is a great idea, I find. But since the mantissa is being truncated, onemust ensure that the narrower width mantissa doesn't end up being all0 bits as that representsinf instead ofnan.
CPython versions tested on:
3.14
Operating systems tested on:
Linux