[issue4114] struct returns incorrect 4 byte float

Robert Withrow report at bugs.python.org
Thu Mar 17 00:25:16 CET 2011


Robert Withrow <bigbaaadbob at gmail.com> added the comment:

I have to disagree.  It seems entirely reasonable to expect that unpack should return the same value passed to pack.  That it doesn't (as of 2.6.5 at least) is completely unexpected and undocumented.  And yes I understand the limitations of floating point numbers.

I suggest that struct should be fixed so that struct.unpack(fmt,struct.pack(fmt,v)) == v and format is something like '!f'.

This can be done in C code (I do it) for IEEE 754 floats.

At the very list this unexpected behavior should be documented in struct.

----------
nosy: +Robert.Withrow

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


More information about the Python-bugs-list mailing list