Raymond Hettinger <raymond.hettin...@gmail.com> added the comment: The suggested examples are misleading because they use 6.24 which is not exactly representable in binary floating point. Representation issues are orthogonal to the OP's issue which is really just a simple rounding example:
>>> x = float.fromhex('0x0.1234560000001') >>> unpack('!f', pack('!f', x))[0].hex() '0x1.2345600000000p-4' Also, if something like the suggested note is adopted, it needs to be worded in a way that doesn't imply that the struct implementation is broken or misdesigned. A better note would focus on the basic (and obvious) fact that downgrading from double precision to single precision entails a loss of precision. ---------- nosy: +rhettinger _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4114> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com