[Previous]
[Contents]
[Next]

ceil()

compute the smallest integer that isn't less than a value

Synopsis:

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

Description:

The ceil() function (ceiling function) computes the smallest integer that isn't less than x.

Returns:

The smallest integer that isn't less than x, expressed as a double.

Examples:

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

void main()
  {
    printf( "%f %f %f %f %f\n", ceil( -2.1 ), 
      ceil( -2. ), ceil( 0.0 ), ceil( 2. ), 
      ceil( 2.1 ) );
  }

produces the output:

-2.000000 -2.000000 0.000000 2.000000 3.000000

Classification:

ANSI

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

floor()


[Previous]
[Contents]
[Next]