-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Document the meaning of values for sys.float_info.rounds #85988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The current docs unnecessarily refer readers to the C99 standard. "integer constant representing the rounding mode used for arithmetic operations. This reflects the value of the system FLT_ROUNDS macro at interpreter startup time. See section 5.2.4.2.2 of the C99 standard for an explanation of the possible values and their meanings." The docs should quote the standard, "The rounding mode for floating-point addition is characterized by the implementation defined value of FLT_ROUNDS: -1 indeterminable, 0 toward zero, 1 to nearest, 2 toward positive infinity, 3 toward negative infinity. All other values for FLT_ROUNDS characterize implementation-defined rounding." |
Also, we should document the meaning of the other fields. Several of them are not self explanatory: min_10_exp = -307 does not mean that 2.3e-308 isn't normalized does mean that 10**-307 is normalized and 10**-308 isn't min_exp = -1021 does not mean that 2**-1021 is the lowest normalized value does mean ldexp(0.5, -1021) == float_info.min decimal_dig = 15 does not mean digits required to specify every unique float does mean, "number of decimal digits, q, such that any |
Python does not set the meaning and the value of these fields itself. It exposes C constants. Should we just copy definitions from corresponding C or floating-point standards? |
Oh, seems it was what Raymond proposed initially. |
Here's a link: http://c0x.coding-guidelines.com/5.2.4.2.2.html |
PR submitted. Please let me know if any changes are required. |
* Change documentation for sys.float_info.rounds Change the documentation for sys.float_info.rounds to remove references to C99 section 5.2.4.2.2 and instead place the available values inline. * Correction to previous documentation change Newlines were not preserved in generated HTML on previous commit. I have changes the list to a comma-separated list of values and their meanings. * Clarify source for value of FLT_ROUNDS Clarify the source of the FLT_ROUNDS value and change 'floating-point addition' to 'floating-point arithmetic' to indicate that the rounding mode applies to all arithmetic operations.
…nGH-99675) * Change documentation for sys.float_info.rounds Change the documentation for sys.float_info.rounds to remove references to C99 section 5.2.4.2.2 and instead place the available values inline. * Correction to previous documentation change Newlines were not preserved in generated HTML on previous commit. I have changes the list to a comma-separated list of values and their meanings. * Clarify source for value of FLT_ROUNDS Clarify the source of the FLT_ROUNDS value and change 'floating-point addition' to 'floating-point arithmetic' to indicate that the rounding mode applies to all arithmetic operations.
…nGH-99675) * Change documentation for sys.float_info.rounds Change the documentation for sys.float_info.rounds to remove references to C99 section 5.2.4.2.2 and instead place the available values inline. * Correction to previous documentation change Newlines were not preserved in generated HTML on previous commit. I have changes the list to a comma-separated list of values and their meanings. * Clarify source for value of FLT_ROUNDS Clarify the source of the FLT_ROUNDS value and change 'floating-point addition' to 'floating-point arithmetic' to indicate that the rounding mode applies to all arithmetic operations.
Uh oh!
There was an error while loading. Please reload this page.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
The text was updated successfully, but these errors were encountered: