Round to largest integral value not greater than x
View other versions (3)
Contents  |
|
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:
#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\n", a, floor(a));
return 0;
}
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.0
Special Values
floor (
±0 ) returns ±0.
floor (
±∞ ) returns ±∞.
See Also
abs,
ceil,
fabsStandards
The
floor functions conform to ISO/IEC 9899:1999(E).
Last Modified: 2009-11-01 08:41:18 Page Rendered: 2010-03-14 00:40:07