round to largest integral value not greater than x

You're viewing an older version of this page (#3247). View the current version.

View versions (3)

NAME

floor

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;a<13;a+=0.1)
    printf("floor of  %.1lf is  %.1lf\n", a, floor(a));
  return 0;
}

Output:

floor of  12.0 is  12.0
floor of  12.1 is  12.0
floor of  12.2 is  12.0
floor of  12.3 is  12.0
floor of  12.4 is  12.0
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

SPECIAL VALUES

floor ( &plusmn;0 ) returns &plusmn;0.
floor ( &plusmn;&infin;) returns &plusmn;&infin;.

SEE ALSO

abs (3) , ceil (3) , fabs (3)

STANDARDS

The floor functions conform to ISO/IEC 9899:1999(E).