diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst index 2af5dfce9612b37..daf8e80592cced9 100644 --- a/Doc/library/decimal.rst +++ b/Doc/library/decimal.rst @@ -638,6 +638,12 @@ Decimal objects >>> Decimal(2).fma(3, 5) Decimal('11') + >>> with localcontext(ExtendedContext): + ... a, b, c = map(Decimal, ['888565290', '1557.96930', + ... '-86087.7578']) + ... a.fma(b, c), a*b + c + ... + (Decimal('1.38435736E+12'), Decimal('1.38435735E+12')) .. method:: is_canonical() diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index 0a8308d9ebce7a7..0ea1658acd49067 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -4945,12 +4945,18 @@ self*other. >>> Decimal(2).fma(3, 5) Decimal('11') + >>> with localcontext(ExtendedContext): + ... a, b, c = map(Decimal, ['888565290', '1557.96930', + ... '-86087.7578']) + ... a.fma(b, c), a*b + c + ... + (Decimal('1.38435736E+12'), Decimal('1.38435735E+12')) [clinic start generated code]*/ static PyObject * _decimal_Decimal_fma_impl(PyObject *self, PyTypeObject *cls, PyObject *other, PyObject *third, PyObject *context) -/*[clinic end generated code: output=db49a777e85b71e4 input=2104c001f6077c35]*/ +/*[clinic end generated code: output=db49a777e85b71e4 input=cf13278e863e8269]*/ Dec_TernaryFuncVA(mpd_qfma) /* Boolean functions, no context arg */ diff --git a/Modules/_decimal/clinic/_decimal.c.h b/Modules/_decimal/clinic/_decimal.c.h index b09200845d12e98..221e74d5a5c432f 100644 --- a/Modules/_decimal/clinic/_decimal.c.h +++ b/Modules/_decimal/clinic/_decimal.c.h @@ -2262,7 +2262,13 @@ PyDoc_STRVAR(_decimal_Decimal_fma__doc__, "self*other.\n" "\n" " >>> Decimal(2).fma(3, 5)\n" -" Decimal(\'11\')"); +" Decimal(\'11\')\n" +" >>> with localcontext(ExtendedContext):\n" +" ... a, b, c = map(Decimal, [\'888565290\', \'1557.96930\',\n" +" ... \'-86087.7578\'])\n" +" ... a.fma(b, c), a*b + c\n" +" ...\n" +" (Decimal(\'1.38435736E+12\'), Decimal(\'1.38435735E+12\'))"); #define _DECIMAL_DECIMAL_FMA_METHODDEF \ {"fma", _PyCFunction_CAST(_decimal_Decimal_fma), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Decimal_fma__doc__}, @@ -6980,4 +6986,4 @@ _decimal_Context_same_quantum(PyObject *context, PyTypeObject *cls, PyObject *co #ifndef _DECIMAL_CONTEXT_APPLY_METHODDEF #define _DECIMAL_CONTEXT_APPLY_METHODDEF #endif /* !defined(_DECIMAL_CONTEXT_APPLY_METHODDEF) */ -/*[clinic end generated code: output=b288181c82fdc9f1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3fb4ae83e095abfe input=a9049054013a1b77]*/