ceil - C math.h

C examples for math.h:ceil

Type

function

From

<cmath>
<ctgmath>
<math.h>

Description

Round up value

Prototype

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

Parameters

Parameter Description
x Value to round up.

Return Value

The smallest integral value that is not less than x.

Example

Demo Code

#include <stdio.h>
#include <math.h> /* ceil */

int main ()/*w  w  w . ja v a2 s .  co m*/
{
  printf ( "%.1f\n", ceil(2.1) );
  printf ( "%.1f\n", ceil(3.9) );
  printf ( "%.1f\n", ceil(-2.1) );
  printf ( "%.1f\n", ceil(-3.9) );
  return 0;
}

Related Tutorials