[issue4114] struct returns incorrect 4 byte float
Martin v. Löwis
report at bugs.python.org
Tue Oct 14 00:22:51 CEST 2008
Martin v. Löwis <martin at v.loewis.de> added the comment:
> "Python is just reflecting what C is doing": the problem is deeper in
> the silicium. If you want a better precision, use an arbitrary
> precision float type like decimal.Decimal() or the GMP library
> (Python: gmpy)
The problem is indeed deeper, however, I doubt GMP is an answer here:
we are talking about the struct module, which, *by design* gives access
to 32-bit (inprecise) floating point numbers - not because people
deliberately want to perform computations inaccurately, but because
there is often a need to interface with this specific representation
(which originally probably was created for its own reasons, such as
to save space, or because some hardware didn't support double
precision).
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4114>
_______________________________________
More information about the Python-bugs-list
mailing list