Issue 10925: Document pure Python version of integer-to-float correctly-rounded conversion (original) (raw)

Issue10925

Created on 2011-01-17 13:00 by mark.dickinson, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pure_python_long_to_float.patch mark.dickinson,2011-01-17 13:00 review
pure_python_long_to_float_v2.patch mark.dickinson,2011-10-22 18:55 review
Messages (4)
msg126398 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2011-01-17 13:00
It would be helpful (perhaps to developers of alternative implementations) to give a pure Python version of correctly-rounded long-to-float conversion. Attached is such a version, as a patch to test_long in the release27-maint branch.
msg126794 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-01-21 23:28
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
msg146177 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2011-10-22 18:55
Thanks for the comments. Here's an updated patch, that actually makes use of the pure Python version to test the built-in int-to-float conversion.
msg146247 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-10-23 19:07
New changeset 117d51d3dd7d by Mark Dickinson in branch 'default': Issue #10925: Add equivalent pure Python code for the builtin int-to-float conversion to test_long. http://hg.python.org/cpython/rev/117d51d3dd7d
History
Date User Action Args
2022-04-11 14:57:11 admin set github: 55134
2011-10-23 19:08:13 mark.dickinson set status: open -> closedresolution: fixedstage: resolved
2011-10-23 19:07:54 python-dev set nosy: + python-devmessages: +
2011-10-22 18:55:07 mark.dickinson set files: + pure_python_long_to_float_v2.patchmessages: + versions: - Python 2.7, Python 3.2
2011-01-21 23:28:46 terry.reedy set nosy: + terry.reedymessages: +
2011-01-17 13:01:07 mark.dickinson set type: enhancementcomponents: + Tests
2011-01-17 13:00:41 mark.dickinson create