Floor division is a division operation that rounds the result down to the nearest whole number or integer, which is less than or equal to the normal division result. The floor function is mathematically denoted by this ⌊ ⌋
symbol.
Let’s understand this concept through the slides below:
Several programming languages have a specific built-in function or operator for calculating floor division.
floor()
method is used in C++Math.floor()
is used in Java//
operator is used in PythonHere is the coding example of floor division in C++.
#include <iostream>//include math library#include <cmath>using namespace std;int main() {// floor() method is used.cout << "Floor of 36/5 is " << floor((double)36/5) << endl;return 0;}
Here is the coding example of floor division in Java.
class FloorDivision {public static void main( String args[] ) {System.out.print( "Floor of 36/5 is " );//Math.floor() method is used below:System.out.println(Math.floor((double)36/5));}}
Here is the coding example of floor division in Python.
print("Floor of 36/5 is")print(36//5)