[issue3166] Make conversions from long to float correctly rounded.

Alexander Belopolsky report at bugs.python.org
Tue Dec 9 19:27:19 CET 2008


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

On Tue, Dec 9, 2008 at 12:39 PM, Mark Dickinson <report at bugs.python.org> wrote:
..
> What would using Python's integer type solve, that isn't already solved by
> the patch?
>

Speaking for myself, it would alleviate the irrational fear of
anything involving the FPU. :-)

Seriously, it is not obvious that your algorithm is correct and does
not depend on x being stored in an extended precision register.
Floating point experts are in short supply, so it may take a while for
your patch to be thoroughly reviewed by one of them.  If you could
produce a formal proof of correctness of your algorithm, that would be
more helpful than code comments.

On the other hand, an implementation that uses only integer
arithmetics plus bit shifts is likely to be much easier to understand.
 I don't think the performance will suffer much.  We can even start
with a pure python prototype using struct.pack or ctypes to produce
the double result.

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


More information about the Python-bugs-list mailing list