floor - floor function
#include <math.h> double floor(double x);
The floor() function computes the largest integral value not greater than x.An application wishing to check for error situations should set errno to 0 before calling floor(). If errno is non-zero on return, or the return value is NaN, an error has occurred.
Upon successful completion, floor() returns the largest integral value not greater than x, expressed as a double.If x is NaN, NaN is returned and errno may be set to [EDOM].
If the correct value would cause overflow, -HUGE_VAL is returned and errno is set to [ERANGE].
If x is ±Inf or ±0, the value of x is returned.
The floor() function will fail if:
- [ERANGE]
- The result would cause an overflow.
The floor() function may fail if:
- [EDOM]
- The value of x is NaN.
No other errors will occur.
None.
The integral value returned by floor() as a double might not be expressible as an int or long int. The return value should be tested before assigning it to an integer type to avoid the undefined results of an integer overflow.The floor() function can only overflow when the floating point representation has DBL_MANT_DIG > DBL_MAX_EXP.
None.
ceil(), isnan(), <math.h>.
Derived from Issue 1 of the SVID.