[issue3166] Make conversions from long to float correctly rounded.
report at bugs.python.org
Thu Apr 2 19:16:03 CEST 2009
Mark Dickinson <dickinsm at gmail.com> added the comment:
Updated patch; applies cleanly to current trunk. No significant changes.
Note that there's now a new reason to apply this patch: it ensures that
the result of a long->float conversion is independent of whether we're
using 30-bit digits or 15-bit digits for longs.
One problem: if long->float conversions are correctly rounded, then
int->float conversions should be correctly rounded as well. (And ideally,
we should have float(int(n)) == float(long(n)) for any integer n.)
This problem only affects 64-bit machines: on 32-bit machines, all
integers are exactly representable as floats, and the C99 standard
specifies that in that case the conversion should be exact.
Added file: http://bugs.python.org/file13582/long_as_double4.patch
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list