Important: The information in this document is obsolete and should not be used for new development.
floor
You can use thefloor
function to round a real number downward to the next integer value.
double_t floor (double_t x);
x
- Any floating-point number.
DESCRIPTION
Thefloor
function rounds its argument downward. This is an ANSI standard C library function. The result is returned in a floating-point data type.This function is the same as performing the following code sequence:
r = fegetround(); /* save current rounding direction */ fesetround(FE_DOWNWARD); /* round downward */ rint(x); /* round to integer */ fesetround(r); /* restore rounding direction */EXCEPTIONS
When x is finite and nonzero, the result of is exact.SPECIAL CASES
Table 9-4 shows the results when the argument to thefloor
function is a zero, a NaN, or an Infinity.
Special cases for the floor
functionOperation Result Exceptions raised +0 None None NaN None[15] + None None EXAMPLES
z = floor(+INFINITY); /* z = +INFINITY because + is already an integer value by definition. */ z = floor(300.1); /* z = 300.0 */ z = floor(-300.1); /* z = -301.0 */
[15] If the NaN is a signaling NaN, the invalid exception is raised.