Important: The information in this document is obsolete and should not be used for new development.
ceil
You can use theceil
function to round a real number upward to the nearest integer value.
double_t ceil (double_t x);
x
- Any floating-point number.
DESCRIPTION
Theceil
function rounds its argument upward. This is an ANSI standard C library function. The result is returned in a floating-point data type.This function is the same as performing the following code sequence:
r = fegetround(); /* save current rounding direction */ fesetround(FE_UPWARD); /* round upward */ rint(x); /* round to integer */ fesetround(r); /* restore rounding direction */EXCEPTIONS
When x is finite and nonzero, the result of is exact.SPECIAL CASES
Table 9-3 shows the results when the argument to theceil
function is a zero, a NaN, or an Infinity.
Special cases for the ceil
functionOperation Result Exceptions raised +0 None None NaN None[14] + None None EXAMPLES
z = ceil(+INFINITY); /* z = +INFINITY because +INFINITY is already an integer value by definition. */ z = ceil(300.1); /* z = 301.0 */ z = ceil(-300.1); /* z = -300.0 */
[14] If the NaN is a signaling NaN, the invalid exception is raised.