[issue3166] Make conversions from long to float correctly rounded.
STINNER Victor
report at bugs.python.org
Wed Nov 5 00:17:59 CET 2008
STINNER Victor <victor.stinner at haypocalc.com> added the comment:
You may use "if (nbits == (size_t)-1 && PyErr_Occurred())" to check
_PyLong_NumBits() error (overflow). Well, "if (numbits > DBL_MAX_EXP)"
should already catch overflow, but I prefer explicit test to check the
error case.
Anyway, interresting patch! Python3 vanilla:
>>> n = 295147905179352891391; int(float(n)) - n
-65535
Python3 + your patch:
>>> int(float(n)) - n
1
----------
stage: -> patch review
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3166>
_______________________________________
More information about the Python-bugs-list
mailing list