New submission from Huang Yang <[email protected]>:
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 <[email protected]>
<https://bugs.python.org/issue43940>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com