[issue3166] Make conversions from long to float correctly rounded.
report at bugs.python.org
Tue Dec 9 17:51:56 CET 2008
Mark Dickinson <dickinsm at gmail.com> added the comment:
> I also wonder whether round to nearest float can be implemented
> floating point arithmetics. I would think round towards zero should
> a simple matter of extracting an appropriate number of bits from the
> long and round to nearest would at most require a long addition.
The idea's attractive. The problem is finding an integer type that's
guaranteed to have enough bits to store the mantissa for the float
(probably plus one or two bits more for comfort); for IEEE 754 this
means a 64-bit integer type, and there aren't any of those in C89.
(One could use two 32-bit integer variables, but that's going to get
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list