Copyright © 1997 The Open Group

floor - floor function

`#include <math.h> double floor(double`

x);

Thefloor()function computes the largest integral value not greater thanx.An application wishing to check for error situations should set

errnoto 0 before callingfloor(). Iferrnois non-zero on return, or the return value is NaN, an error has occurred.

Upon successful completion,floor()returns the largest integral value not greater thanx, expressed as adouble.If

xis NaN, NaN is returned anderrnomay be set to [EDOM].If the correct value would cause overflow, -HUGE_VAL is returned and

errnois set to [ERANGE].If

xis ±Inf or ±0, the value ofxis returned.

Thefloor()function will fail if:

- [ERANGE]
- The result would cause an overflow.
The

floor()function may fail if:

- [EDOM]
- The value of
xis NaN.No other errors will occur.

None.

The integral value returned byfloor()as adoublemight not be expressible as anintorlong int. The return value should be tested before assigning it to an integer type to avoid the undefined results of an integer overflow.The

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

None.

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

Derived from Issue 1 of the SVID.

Copyright © 1997 The Open Group

[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]