[Previous]
[Contents]
[Next]

floor()

compute the largest integer not greater than a number

Synopsis:

#include <math.h>
double floor( double x );

Description:

The floor() function computes the largest integer not greater than x.

Returns:

the largest integer not greater than x, expressed as a double.

Examples:

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

void main()
  {
    printf( "%f\n", floor( -3.14 ) );
    printf( "%f\n", floor( -3. ) );
    printf( "%f\n", floor( 0. ) );
    printf( "%f\n", floor( 3.14 ) );
    printf( "%f\n", floor( 3. ) );
  }

produces the output

-4.000000
-3.000000
0.000000
3.000000
3.000000

Classification:

ANSI

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

ceil(), fmod()


[Previous]
[Contents]
[Next]