diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst index 2af5dfce9612b3..daf8e80592cced 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 2760792a3fe18e..eef6dd7c1e58bf 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -4952,12 +4952,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 c803006ad44382..5c5590ae6f5f6b 100644 --- a/Modules/_decimal/clinic/_decimal.c.h +++ b/Modules/_decimal/clinic/_decimal.c.h @@ -2263,7 +2263,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__}, @@ -6984,4 +6990,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=0eb835634388294e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=c7299b41a26a58c2 input=a9049054013a1b77]*/