floor [C++ Reference]
Keywords: c,math,floor
Date: 2009-09-08T04:12:24-0700

[[floor]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## floor

Syntax:

        #include <cmath>
        double floor( double arg );

The function floor() returns the largest integer not greater than arg. For example,

         y = 6.04;
         x = floor( y );

would result in x being set to 6.0. Note that the reverse is true when arg<0; in other words, this function effectively chops off everything after the decimal point.

C++ also provides the following overloaded forms:

        #include <cmath>
        float floor( float arg ); // same as floorf() in C99
        long double floor( long double arg ); // same as floorl() in C99

Related Topics: ceil, fmod

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •