diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst index ecd973a070b3dff..aae1883f029ed2b 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 ada9b02d690717f..885554c310460f9 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -5013,12 +5013,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 8ad883d8a2d14dc..735877a1f68f76c 100644 --- a/Modules/_decimal/clinic/_decimal.c.h +++ b/Modules/_decimal/clinic/_decimal.c.h @@ -2379,7 +2379,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__}, @@ -7100,4 +7106,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=718b1f6c20412350 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e93e474ae062e073 input=a9049054013a1b77]*/