function
<cmath> <ctgmath>

ceil

double ceil (double x);
double ceil  (double x);
float ceilf (float x);
long double ceill (long double x);
double ceil (double x);
float ceil (float x);
long double ceil (long double x);
double ceil (double x);
float ceil (float x);
long double ceil (long double x);
Round up value
Rounds x upward, returning the smallest integral value that is not less than x.

Header <tgmath.h> provides a type-generic macro version of this function.
Additional overloads are provided in this header (<cmath>) for the integral types: These overloads effectively cast x to a double before calculations (defined for T being any integral type).

Parameters

x
Value to round up.

Return Value

The smallest integral value that is not less than x (as a floating-point value).

Example

 123456789101112 /* ceil example */ #include /* printf */ #include /* ceil */ int main () { printf ( "ceil of 2.3 is %.1f\n", ceil(2.3) ); printf ( "ceil of 3.8 is %.1f\n", ceil(3.8) ); printf ( "ceil of -2.3 is %.1f\n", ceil(-2.3) ); printf ( "ceil of -3.8 is %.1f\n", ceil(-3.8) ); return 0; }

Output:
 ceil of 2.3 is 3.0 ceil of 3.8 is 4.0 ceil of -2.3 is -2.0 ceil of -3.8 is -3.0