fma

Returns (x * y) + z, rounding only once according to the current precision and rounding mode

@IEEECompliant("fusedMultiplyAdd", 4)
fma
(
D1
D2
D3
)
(
auto const ref D1 x
,
auto const ref D2 y
,
auto const ref D3 z
)
if (
isDecimal!(D1, D2, D3)
)

Throws

InvalidOperationExceptionx, y or z is signaling NaN
InvalidOperationException(x, y) = (±∞, ±0.0) or (±0.0, ±∞)
InvalidOperationExceptionx or y is infinite, z is infinite but has opposing sign
UnderflowExceptionresult is too small to be represented
OverflowExceptionresult is too big to be represented
InexactExceptionthe result is inexact

Special values

xyzfma(x, y, z)
NaNanyanyNaN
anyNaNanyNaN
anyanyNaNNaN
±∞±0.0anyNaN
±0.0±∞anyNaN
+∞>0.0-∞NaN
-∞<0.0-∞NaN
-∞<0.0-∞NaN
+∞>0.0-∞NaN
-∞>0.0+∞NaN
+∞<0.0+∞NaN
+∞<0.0+∞NaN
-∞>0.0+∞NaN
>0.0+∞-∞NaN
<0.0-∞-∞NaN
<0.0-∞-∞NaN
>0.0+∞-∞NaN
>0.0-∞+∞NaN
<0.0+∞+∞NaN
<0.0+∞+∞NaN
>0.0-∞+∞NaN
+∞>0.0+∞+∞
-∞<0.0+∞+∞
+∞<0.0-∞-∞
-∞>0.0-∞-∞
>0.0+∞+∞+∞
<0.0-∞+∞+∞
<0.0+∞-∞-∞
>0.0-∞-∞-∞
+∞>0.0any+∞
-∞<0.0any+∞
+∞<0.0any-∞
-∞>0.0any-∞
>0.0+∞any+∞
<0.0-∞any+∞
<0.0+∞any-∞
>0.0-∞any-∞

Examples

decimal32 x = 2;
decimal64 y = 3;
decimal128 z = 5;
assert (fma(x, y, z) == 11);

Meta