Calculates the ceiling of a value.
Include
<math.h>
Prototype
float ceilf(float x);
Argument
x
Return Value
Returns the smallest integer value greater than or equal to
x
.
Remarks
No domain or range error will occur. See floorf
.
Example
#include <math.h>
#include <stdio.h>
int main(void)
{
float x[8] = {2.0F, 1.75F, 1.5F, 1.25F, -2.0F, -1.75F, -1.5F, -1.25F};
float y;
int i;
for (i=0; i<8; i++)
{
y = ceilf (x[i]);
printf("The ceiling for %f is %f\n", x[i], y);
}
}
Example Output
The ceiling for 2.000000 is 2.000000
The ceiling for 1.750000 is 2.000000
The ceiling for 1.500000 is 2.000000
The ceiling for 1.250000 is 2.000000
The ceiling for -2.000000 is -2.000000
The ceiling for -1.750000 is -1.000000
The ceiling for -1.500000 is -1.000000
The ceiling for -1.250000 is -1.000000