Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C |
both |
#include <math.h>
double floor(double x);
float floor(float x); /* C++ only */
long double floor(long double x); /* C++ only */
float floorf(float x);
long double floorl(long double x);
Returns the calculated integral value expressed as a double, float, or long double value. The result cannot have a range error.
⁄* CELEBF24
This example assigns y the value of the largest integer that is less
than or equal to 2.8, and it assigns z the value of the largest integer
that is less than or equal to -2.8.
*⁄
#include <math.h>
#include <stdio.h>
int main(void)
{
double y, z;
y = floor(2.8);
z = floor(-2.8);
printf("floor( 2.8 ) = %f\n", y);
printf("floor( -2.8 ) = %f\n", z);
}
floor( 2.8 ) = 2.000000
floor( -2.8 ) = -3.000000