Skip to content

Commit 953e322

Browse files
committed
gh-65709: provide extra example in Decimal.fma() docs
This demonstrates single rounding.
1 parent 9604fa8 commit 953e322

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

Doc/library/decimal.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,12 @@ Decimal objects
638638

639639
>>> Decimal(2).fma(3, 5)
640640
Decimal('11')
641+
>>> with localcontext(ExtendedContext):
642+
... a, b, c = map(Decimal, ['888565290', '1557.96930',
643+
... '-86087.7578'])
644+
... a.fma(b, c), a*b + c
645+
...
646+
(Decimal('1.38435736E+12'), Decimal('1.38435735E+12'))
641647

642648
.. method:: is_canonical()
643649

Modules/_decimal/_decimal.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4945,12 +4945,18 @@ self*other.
49454945
49464946
>>> Decimal(2).fma(3, 5)
49474947
Decimal('11')
4948+
>>> with localcontext(ExtendedContext):
4949+
... a, b, c = map(Decimal, ['888565290', '1557.96930',
4950+
... '-86087.7578'])
4951+
... a.fma(b, c), a*b + c
4952+
...
4953+
(Decimal('1.38435736E+12'), Decimal('1.38435735E+12'))
49484954
[clinic start generated code]*/
49494955

49504956
static PyObject *
49514957
_decimal_Decimal_fma_impl(PyObject *self, PyTypeObject *cls, PyObject *other,
49524958
PyObject *third, PyObject *context)
4953-
/*[clinic end generated code: output=db49a777e85b71e4 input=2104c001f6077c35]*/
4959+
/*[clinic end generated code: output=db49a777e85b71e4 input=cf13278e863e8269]*/
49544960
Dec_TernaryFuncVA(mpd_qfma)
49554961

49564962
/* Boolean functions, no context arg */

Modules/_decimal/clinic/_decimal.c.h

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)