floor - calculate the floor of a number
floor, floorf, floorl - largest integral value not greater than argument
#include <math.h>
double floor(double x);
#include <math.h>
double floor(double x);
float floorf(float x);
long double floorl(long double x);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
This function returns the floor of x
.
These functions return the largest integral value that is not greater
than x
.
For example, floor(0.5)
is 0.0, and floor(-0.5)
is
-1.0.
This function returns, as a double
, the largest integer that is not greater than x
. You may safely cast that value to a long
(or an int
if it fits).
These functions return the floor of x
.
If x
is integral, +0, -0, NaN, or an infinity, x
itself is returned.
#include <math.h>
#include <stdio.h>
int main(void)
{
printf("This is CS%i\n", (int) floor(50.1));
}