[issue10925] Document pure Python version of integer-to-float correctly-rounded conversion

Terry J. Reedy report at bugs.python.org
Sat Jan 22 00:28:51 CET 2011


Terry J. Reedy <tjreedy at udel.edu> added the comment:

I see there is already something similar for true division.

I find
+    q_max, shift_max = 1 << sig_bits, sys.float_info.max_exp - sig_bits
easier to read as two lines
+    q_max = 1 << sig_bits
+    shift_max = sys.float_info.max_exp - sig_bits

Not having precedence memorized, I prefer added parens here:
+ ...  (n >> shift) | bool(n & (1 << shift) - 1)

I presume that for normal production testing, you would comment out
+       float = long_to_float

----------
nosy: +terry.reedy

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


More information about the Python-bugs-list mailing list