ceil -- Find Integer >= Argument

Format

#include <math.h>
double ceil(double x);

Language Level: ANSI, POSIX, XPG4
ceil computes the smallest integer that is greater than or equal to x.

Return Value
ceil returns the integer as a double value.

Example
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 <stdio.h>
#include <math.h>
int main(void)
{
   double y,z;
   y = ceil(1.05);                                 /* y = 2.0 */
   printf("ceil( 1.05 ) = %5.f\n", y);
   z = ceil(-1.05);                               /* z = -1.0 */
   printf("ceil( -1.05 ) = %5.f\n", z);
   return 0;
   /************************************************************
      The output should be:
      ceil( 1.05 ) =     2
      ceil( -1.05 ) =    -1
   ************************************************************/
}


floor -- Integer <= Argument
fmod -- Calculate Floating-Point Remainder
<math.h>