The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

ceil - ceiling value function

 SYNOPSIS



#include <math.h>

double ceil(double x);

 DESCRIPTION

The ceil() function computes the smallest integral value not less than x.

An application wishing to check for error situations should set errno to 0 before calling ceil(). If errno is non-zero on return, or the return value is NaN, an error has occurred.

 RETURN VALUE

Upon successful completion, ceil() returns the smallest integral value not less than x, expressed as a type double.

If x is NaN, NaN is returned and errno may be set to [EDOM].

If the correct value would cause overflow, HUGE_VAL is returned and errno is set to [ERANGE]. If x is ±Inf or ±0, the value of x is returned.

 ERRORS

The ceil() function will fail if:
[ERANGE]
The result overflows.

The ceil() function may fail if:

[EDOM]
The value of x is NaN.

No other errors will occur.

 EXAMPLES

None.

 APPLICATION USAGE

The integral value returned by ceil() as a double need not be expressible as an int or long int. The return value should be tested before assigning it to an integer type to avoid the undefined results of an integer overflow.

The ceil() function can only overflow when the floating point representation has DBL_MANT_DIG > DBL_MAX_EXP.

 FUTURE DIRECTIONS

None.

 SEE ALSO

floor(), isnan(), <math.h>.

DERIVATION

Derived from Issue 1 of the SVID.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]