ceil - ceiling value function
#include <math.h> double ceil(double x);
The ceil() function computes the smallest integral value not less than x.
An application wishing to check for error situations should set errno to 0 before calling ceil(). If errno is non-zero on return, or the return value is NaN, an error has occurred.
Upon successful completion, ceil() returns the smallest integral value not less than x, expressed as a type 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 ceil() function will fail if:
- The result overflows.
The ceil() function may fail if:
- The value of x is NaN.
No other errors will occur.
The integral value returned by ceil() as a double need 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 ceil() function can only overflow when the floating point representation has DBL_MANT_DIG > DBL_MAX_EXP.
floor(), isnan(), <math.h>.
Derived from Issue 1 of the SVID.