floor
round to largest integral value not greater than x
INTERFACE
#include <math.h>
double floor ( double x )
long floorl ( long double x )
float floorf ( float x )
DESCRIPTION
The floor functions return the largest integral value less than or equal to x.
Example 1
Workings
\code #include <stdio.h> #include <math.h>
int main(void) { for (double a = 12.5; a < 13.4; a += 0.1) printf("floor of %.1lf is %.1lf
", a, floor(a)); return 0; } \endcode
Solution
Output:
floor of 12.5 is 12.0
floor of 12.6 is 12.0
floor of 12.7 is 12.0
floor of 12.8 is 12.0
floor of 12.9 is 12.0
floor of 13.0 is 13.0
floor of 13.1 is 13.0
floor of 13.2 is 13.0
floor of 13.3 is 13.0
floor of 13.4 is 13.0SPECIAL VALUES
floor ( ±0 ) returns ±0.
floor ( ±∞ ) returns ±∞.
SEE ALSO
STANDARDS
The floor functions conform to ISO/IEC 9899:1999(E).