Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C |
both |
#include <math.h>
double ceil(double x);
float ceil(float x); /* C++ only */
long double ceil(long double x); /* C++ only */
float ceilf(float x);
long double ceill(long double x);
Returns the calculated value as a double, float, or long double value.
If there is an overflow, the function sets errno to ERANGE and returns HUGE_VAL.
Special behavior for IEEE: The ceil() functions are always successful.
⁄* CELEBC04
This example sets y to the smallest integer greater than
1.05, and then to the smallest integer greater than -1.05.
The results are 2.0 and -1.0, respectively.
*⁄
#include <math.h>
#include <stdio.h>
int main(void)
{
double y, z;
y = ceil(1.05); ⁄* y = 2.0 *⁄
z = ceil(-1.05); ⁄* z = -1.0 *⁄
printf("y = %f\n z = %f\n", y, z);
}