[New-bugs-announce] [issue43940] int casting to float results to a different value in memory

Huang Yang report at bugs.python.org
Sun Apr 25 22:52:44 EDT 2021


New submission from Huang Yang <yang.huang at intel.com>:

from ctypes import *
import struct

i = int('7f94e57c', 16)
cp = pointer(c_int(i))
fp = cast(cp, POINTER(c_float))
print(fp.contents.value) # nan
print(struct.pack(">f", fp.contents.value).hex()) # 7fd4e57c

# value changed: 7f94e57c -> 7fd4e57c

----------
components: Library (Lib), ctypes
messages: 391876
nosy: yang8621
priority: normal
severity: normal
status: open
title: int casting to float results to a different value in memory
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43940>
_______________________________________


More information about the New-bugs-announce mailing list