Floating-point multiply-add.
The fma, fmaf, fmal, and fmad128 subroutines compute (x * y) + z, rounded as one ternary operation. They compute the value (as if) to infinite precision and round once to the result format, according to the rounding mode characterized by the value of FLT_ROUNDS.
An application wishing to check for error situations should set the errno global variable to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these subroutines. Upon return, if errno is nonzero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is nonzero, an error has occurred.
Item | Description |
---|---|
x | Specifies the value to be multiplied by the y parameter. |
y | Specifies the value to be multiplied by the x parameter. |
z | Specifies the value to be added to the product of the x and y parameters. |
Upon successful completion, the fma, fmaf, fmal, and fmad128 subroutines return (x * y) + z, rounded as one ternary operation.
If x or y are NaN, a NaN is returned.
If x multiplied by y is an exact infinity and z is also an infinity but with the opposite sign, a domain error occurs, and a NaN is returned.
If one of the x and y parameters is infinite, the other is zero, and the z parameter is not a NaN, a domain error occurs, and a NaN is returned.
If one of the x and y parameters is infinite, the other is zero, and z is a NaN, a NaN is returned and a domain error may occur.
If x*y is not 0*Inf nor Inf*0 and z is a NaN, a NaN is returned.