ceil, _ceill

Description

Calculate the ceiling of a value.

#include <math.h>

double ceil( double x);

long double _ceill( long double x);

x Floating-point value  

Remarks

The ceil and _ceill functions return a double (or long double) value representing the smallest integer that is greater than or equal to x.

The _ceill function is the 80-bit counterpart and it uses the 80-bit, 10-byte coprocessor form of arguments and return values. See the reference page on the long double functions for more details on this data type.

Return Value

These functions return the double or long double result. There is no error return.

Compatibility

ceil

Standards:ANSI, UNIX

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

_ceill

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:None

See Also

floor, fmod

Example

/* FLOOR.C: This example displays the largest integers less than or equal

* to the floating-point values 2.8 and -2.8. It then shows the smallest

* integers greater than or equal to 2.8 and -2.8.

*/

#include <math.h>

#include <stdio.h>

void main( void )

{

double y;

y = floor( 2.8 );

printf( "The floor of 2.8 is %f\n", y );

y = floor( -2.8 );

printf( "The floor of -2.8 is %f\n", y );

y = ceil( 2.8 );

printf( "The ceil of 2.8 is %f\n", y );

y = ceil( -2.8 );

printf( "The ceil of -2.8 is %f\n", y );

}

Output

The floor of 2.8 is 2.000000

The floor of -2.8 is -3.000000

The ceil of 2.8 is 3.000000

The ceil of -2.8 is -2.000000