# Floor division operator in python

## Introduction to Python floor divisionSuppose you have a division of two integers:
In this division, 101 is called a numerator ( The integer division 101 / 4 returns 25 with the remainder 1. In other words:
Or put it in another way:
Python
uses two operators
The This tutorial focuses on the floor division operator. You’ll learn about the modulo operator in the following tutorial. Both floor division and modulo operators satisfy the following equation:
Generally, if
To understand the floor division, you first need to understand the floor of a real number. The floor of a real number is the largest integer less than or equal to the number. In other words:
For example, the floor of 3.4 is 3 because 3 is the largest integer less than or equal to 3.4. The floor of 3.9 is also 3. And the floor of 3 is 3 obviously:
For the positive numbers, it would be easy to understand the definition. However, you should pay attention when it comes to negative numbers. For example, the floor of
The floor division can be defined as:
Notice that the floor division of a number is not always the same as truncation. The floor division is the same as truncation only when the numbers are positive. ## Python floor division operator examplesThe following example uses the floor division operators with positive and negative integers:
Output:
The following table illustrates the floor division of two integers
## Python math.floor() functionThe
Output:
As you can see clearly from the output, the
Output:
## Summary- Python uses // as the floor division operator and
`%` as the modulo operator. - If the numerator is N and the denominator D, then this equation
`N = D * ( N // D) + (N % D)` is always satisfied. - Use floor division operator
`//` or the`floor()` function of the`math` module to get the floor division of two integers.
Did you find this tutorial helpful ? |

**Floor division operator in python**