[issue4114] struct returns incorrect 4 byte float

TD22057 report at bugs.python.org
Mon Oct 13 19:11:43 CEST 2008


New submission from TD22057 <ted.drain at jpl.nasa.gov>:

FYI Actual version is 2.5.2 running on Linux RHE4.

>>> import struct
>>> fmt ='>f'
>>> v=1.8183e-7
>>> v
1.8183000000000001e-07
>>> s=struct.pack(fmt,v)
>>> struct.unpack(fmt,s)
(1.818300034983622e-07,)

Looks to me like the float->double conversion is not being zeroed out
before the 4 bytes are written to it.  FYI this is a fairly serious
issue since it leads to incorrect results be read from files (at least
for me anyway).

----------
components: Extension Modules
messages: 74690
nosy: TD22057
severity: normal
status: open
title: struct returns incorrect 4 byte float
type: behavior
versions: Python 2.5.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4114>
_______________________________________


More information about the Python-bugs-list mailing list