floor, floorl
raw OCR
Rounds down.
Defined in header <math.h>
Syntax
#include <math.h>
double floor(double x);
long double floorl(long double x);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only | |
|---|---|---|---|---|---|
| floor | ■ | ■ | ■ | ■ | |
| ■ | ■ |
Remarks
floor finds the largest integer not greater than x. floorl is the long double version; it takes a long double argument and returns a long double result.
Return value
floor returns the integer found as a double. floorl returns the integer found as a long double.
See also
Example
#include <stdio.h>
#include <math.h>
int main(void)
{
double number = 123.54, down, up;
down = floor (number);
up = ceil (number);
printf("original number %10.21f\n", number);
printf("number rounded doivn %10.21f\n", down);
printf("number rounded up U0.21f\n", up);
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/math.h/floor/
· short form /3.1/floor/