floor()

Declaration

double floor(double dX);

Description:

This function returns the floor or the largest integer that is less than or equal to the passed-in argument.

Overloads

float floor(float);
double floor(double);
long double floor(long double);

Related Functions

float floorf(float);
long double floorl(long double);

* Note: Since C does not allow function overloading, these other versions of this function exist.

Domain

(-∞, ∞)

Range

(0, ∞)

Periodicity

None

Symmetry

None

Asymptotes

None





Example

#include <iostream>
#include <cmath>

int main() {
    using namespace std;

    double dX = -1000.0;
    cout << "x = " << dX << "  floor(x) = " << floor(dX) << endl;

    dX = 1.8;
    cout << "x = " << dX << "  floor(x) = " << floor(dX) << endl;

    return 0;
}

Output:

floor() Output