Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f56c3612
Commit
f56c3612
authored
Nov 18, 2012
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Plain Diff
Issue #12005: merge doc patch from 3.2
parents
8572da5e
a3f37408
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
Doc/library/decimal.rst
Doc/library/decimal.rst
+23
-0
No files found.
Doc/library/decimal.rst
View file @
f56c3612
...
...
@@ -400,6 +400,29 @@ Decimal objects
compared, sorted, and coerced to another type (such as :class:`float` or
:class:`int`).
There are some small differences between arithmetic on Decimal objects and
arithmetic on integers and floats. When the remainder operator ``%`` is
applied to Decimal objects, the sign of the result is the sign of the
*dividend* rather than the sign of the divisor::
>>> (-7) % 4
1
>>> Decimal(-7) % Decimal(4)
Decimal('-3')
The integer division operator ``//`` behaves analogously, returning the
integer part of the true quotient (truncating towards zero) rather than its
floor, so as to preseve the usual identity ``x == (x // y) * y + x % y``::
>>> -7 // 4
-2
>>> Decimal(-7) // Decimal(4)
Decimal('-1')
The ``%`` and ``//`` operators implement the ``remainder`` and
``divide-integer`` operations (respectively) as described in the
specification.
Decimal objects cannot generally be combined with floats or
instances of :class:`fractions.Fraction` in arithmetic operations:
an attempt to add a :class:`Decimal` to a :class:`float`, for
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment