Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

struct (un)packing of half-precision may turn NaN into ±inf #141042

Open
Labels
3.14bugs and security fixes3.15new features, bugs and security fixesextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error
@robsdedude

Description

@robsdedude

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

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15new features, bugs and security fixesextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp