[issue4114] struct returns incorrect 4 byte float

Martin v. Löwis report at bugs.python.org
Thu Mar 17 17:35:11 CET 2011


Martin v. Löwis <martin at v.loewis.de> added the comment:

> Martin: in C I have the luxury of using 32 bit floats; not an option
> in Python.  Simple code doing the moral equivalent of NTOHL(HTONL())
> works in this case for C but wouldn't help for Python.

If you agree that Python actually behaves correct, I fail to
understand what it is that you disagree with in msg131195

If all you want is a documentation change, can you please propose
specific wording?

> Even worse, there is no straightforward way (that I'm aware of) to
> write portable tests for code using the 'f' format character.

If you use numbers that are exactly representable as floats,
the test should be portable to all platforms that use 32-bit
IEEE-754 floats. If you then also use numbers without a fractional
part, it should even port to non-IEEE platforms (as long as you
don't test for the intermediate bytes).

[...]
> This test will fail when you use the 'f' format code.

So use 6.25 instead.

----------

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


More information about the Python-bugs-list mailing list