floorl Function

Calculates the floor of a double precision floating-point value.

Include

<math.h>

Prototype

long double floor (long double x);

Argument

x
floating-point value for which to return the floor

Return Value

Returns the largest integer value less than or equal to x.

Remarks

No domain or range error will occur. See ceil.

Example

#include <math.h>
#include <stdio.h>

int main(void)
{
  long double x[8] = {2.0, 1.75, 1.5, 1.25, -2.0, 
                 -1.75, -1.5, -1.25};
  long double y;
  int i;

  for (i=0; i<8; i++)
  {
    y = floor (x[i]);
    printf("The ceiling for %Lf is %Lf\n", x[i], y);
  }
}

Example Output

The  floor for 2.000000 is 2.000000
The  floor for 1.750000 is 1.000000
The  floor for 1.500000 is 1.000000
The  floor for 1.250000 is 1.000000
The  floor for -2.000000 is -2.000000
The  floor for -1.750000 is -2.000000
The  floor for -1.500000 is -2.000000
The  floor for -1.250000 is -2.000000