summaryrefslogtreecommitdiffstats
path: root/Doc/library/decimal.rst
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2015-12-28 22:02:02 (GMT)
committerStefan Krah <skrah@bytereef.org>2015-12-28 22:02:02 (GMT)
commit53f2e0ad45e41c007f714e077ccf11643651ef28 (patch)
treec00ffd5dd955b9685de5c1a12fd014745b22f361 /Doc/library/decimal.rst
parentac1e7f6983ef4f0feef6389d458544bf924f6965 (diff)
downloadcpython-53f2e0ad45e41c007f714e077ccf11643651ef28.zip
cpython-53f2e0ad45e41c007f714e077ccf11643651ef28.tar.gz
cpython-53f2e0ad45e41c007f714e077ccf11643651ef28.tar.bz2
Issue #25928: Add Decimal.as_integer_ratio(). Python parts and docs by
Mark Dickinson.
Diffstat (limited to 'Doc/library/decimal.rst')
-rw-r--r--Doc/library/decimal.rst13
1 files changed, 13 insertions, 0 deletions
diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst
index 2de0ea0..14356aa 100644
--- a/Doc/library/decimal.rst
+++ b/Doc/library/decimal.rst
@@ -448,6 +448,19 @@ Decimal objects
``Decimal('321e+5').adjusted()`` returns seven. Used for determining the
position of the most significant digit with respect to the decimal point.
+ .. method:: as_integer_ratio()
+
+ Return a pair ``(n, d)`` of integers that represent the given
+ :class:`Decimal` instance as a fraction, in lowest terms and
+ with a positive denominator::
+
+ >>> Decimal('-3.14').as_integer_ratio()
+ (-157, 50)
+
+ The conversion is exact. Raise OverflowError on infinities and ValueError
+ on NaNs.
+
+ .. versionadded:: 3.6
.. method:: as_tuple()