Computes the floating-point remainder value.
The fmodf, fmodl, fmod, fmodd32, fmodd64, and fmodd128 subroutines return the floating-point remainder of the division of x by y.
An application that wants to check for error situations must set the errno global variable to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these subroutines. On return, if errno is the value of non-zero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is the value of non-zero, an error has occurred.
Item | Description |
---|---|
x | Specifies the value to be computed. |
y | Specifies the value to be computed. |
The fmodf, fmodl, fmod, fmodd32, fmodd64, and fmodd128 subroutines return the value x- i *y. For the integer i such that, if y is nonzero, the result has the same sign as x and the magnitude is less than the magnitude of y.
If the correct value will cause underflow, and is not representable, a range error might occur, and 0.0 is returned.
If x or y is NaN, a NaN is returned.
If y is zero, a domain error occurs, and a NaN is returned.
If x is infinite, a domain error occurs, and a NaN is returned.
If x is ±0 and y is not zero, ±0 is returned.
If x is not infinite and y is ±Inf, x is returned.
If the correct value will cause underflow, and is representable, a range error might occur and the correct value is returned.
If the correct value is zero, rounding error might cause the return value to differ from 0.0. Depending on the values of x and y, and the rounding mode, the magnitude of the return value in this case might be near 0.0 or near the magnitude of y. This case can be avoided by using the decimal floating-point subroutines (fmodd32, fmodd64, and fmodd128).