C++ std::floor — rounding down

In C++, std::floor rounds toward negative infinity. The floor of 2.3 is 2, the floor of −2.3 is −3, and 2 stays 2.

A simple example

std::floor

  1. Start with 2.8
  2. Do this Round downward to a whole number
  3. Result 2
Two is the greatest integer at or below 2.8.
lesson.cpp
#include <iostream>
#include <cmath>

int main() {
    std::cout << (std::floor(2.8)) << '\n';
}
Output
2