compute the largest integer not greater than a number
#include <math.h> double floor( double x );
The floor() function computes the largest integer not greater than x.
the largest integer not greater than x, expressed as a double.
#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
ANSI
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | Yes |