8000 GH-105774: Clarify operation of normalize() by rhettinger · Pull Request #106093 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-105774: Clarify operation of normalize() #106093

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

Merged
merged 4 commits into from
Jun 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Match indentation of other sections
  • Loading branch information
rhettinger committed Jun 25, 2023
commit 3aba7fc302c07f14dff2fa7ef30b1c8f78fab2d3
20 changes: 10 additions & 10 deletions Doc/library/decimal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2098,16 +2098,16 @@ precision than current context. Computations process with those
exact inputs and then rounding (or other context operations) is
applied to the *result* of the computation::

>>> getcontext().prec = 5
>>> pi = Decimal('3.1415926535') # More than 5 digits
>>> pi # All digits are retained
Decimal('3.1415926535')
>>> pi + 0 # Rounded after an addition
Decimal('3.1416')
>>> pi - Decimal('0.00005') # Subtract unrounded numbers, then round
Decimal('3.1415')
>>> pi + 0 - Decimal('0.00005'). # Intermediate values are rounded
Decimal('3.1416')
>>> getcontext().prec = 5
>>> pi = Decimal('3.1415926535') # More than 5 digits
>>> pi # All digits are retained
Decimal('3.1415926535')
>>> pi + 0 # Rounded after an addition
Decimal('3.1416')
>>> pi - Decimal('0.00005') # Subtract unrounded numbers, then round
Decimal('3.1415')
>>> pi + 0 - Decimal('0.00005'). # Intermediate values are rounded
Decimal('3.1416')

Q. Some decimal values always print with exponential notation. Is there a way
to get a non-exponential representation?
Expand Down
0