round to smallest integral value not less than x

You're viewing an older version of this page (#3428). View the current version.

View versions (4)

INTERFACE

#include <math.h>

double ceil ( double x ) long ceill ( long double x ) float ceilf ( float x )

DESCRIPTION

The ceil function returns the smallest integral value greater than or equal to x.

Example 1

#include <stdio.h>
#include <math.h>

int main(void)
{
  for(double a = 12; a < 13; a += 0.1)
    printf("ceil of  %.1lf is  %.1lf\n", a, ceil(a));
  return 0;
}

Output

ceil of  12.0 is  12.0
ceil of  12.1 is  13.0
ceil of  12.2 is  13.0
ceil of  12.3 is  13.0
ceil of  12.4 is  13.0
ceil of  12.5 is  13.0
ceil of  12.6 is  13.0
ceil of  12.7 is  13.0
ceil of  12.8 is  13.0
ceil of  12.9 is  13.0
ceil of  13.0 is  13.0

SPECIAL VALUES

ceil ( &plusmn;0 ) returns &plusmn;0.
ceil ( &plusmn;&infin ) returns &plusmn;&infin;.

SEE ALSO

abs, fabs, floor

STANDARDS

The ceil function conform to ISO/IEC 9899:1999(E).