I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
ComputingCMath.h

floorf

Round to largest integral value not greater than x
+ View other versions (4)

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:
Example - Round to largest integral value not greater than x
Workings
#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;
}
Solution
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 ±∞.

Standards

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