##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# floor

From cppreference.com
< c‎ | numeric‎ | math

Defined in header `<math.h>` |  |
float floorf( float arg ); |  | (since C99)
double floor( double arg ); |  |
long double floorl( long double arg ); |  | (since C99)

Computes nearest integer not greater than `arg`.

### [edit] Parameters

arg | - | floating point value

### [edit] Return value

Nearest integer not greater than `arg`

### [edit] Notes

The integer value can be always represented by the given floating point type.

### [edit] Example

Run this code

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

    void report_floorf(float f) {
    	printf("floorf(%5.2f)=%5.2f\n",f,floorf(f));
    } /* end report_floorf() */

    void demo_floorf() {
    	report_floorf(9.1f);
    	report_floorf(-9.1f);
    	report_floorf(0.0f);
    } /* end demo_floorf() */

Output:

    floorf( 9.10)= 9.00
    floorf(-9.10)=-10.00
    floorf( 0.00)= 0.00

### [edit] See also

ceil | nearest integer not less than the given value (function) [edit]
trunc (C99) | nearest integer not greater in magnitude than the given value (function) [edit]
round lround llround (C99)(C99)(C99) | nearest integer, rounding away from zero in halfway cases (function) [edit]
C++ documentation for floor

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/numeric/math/floor&oldid=62577"