What Is Floor Division?
Floor division, also known as integer division or division with remainder, is an operation where you divide two numbers and round the result down to the nearest whole number (integer). The mathematical symbol for this is the floor function: ⌊a ÷ b⌋.
In other words, floor division always gives you the largest integer that does not exceed the exact quotient. For example:
- 13 ÷ 4 = 3.25 → floor division gives 3
- 26 ÷ 5 = 5.2 → floor division gives 5
- 76 ÷ 13 ≈ 5.846 → floor division gives 5
- −7 ÷ 2 = −3.5 → floor division gives −4 (rounds toward −∞, not toward 0!)
Floor Division vs. Regular Division
The key difference between floor division and regular division is the result type:
- Regular division returns a decimal (e.g., 13 ÷ 4 = 3.25)
- Floor division returns an integer (e.g., ⌊13 ÷ 4⌋ = 3)
Floor division always rounds toward negative infinity, which is important for negative numbers. This is different from truncated division (used in C and Java), which rounds toward zero.
Floor Division Formula
The floor division formula is:
q = ⌊a ÷ b⌋
r = a − q × b
a = q × b + r
Where:
- a — the dividend (number being divided)
- b — the divisor (number you divide by)
- q — the floor quotient (floor division result)
- r — the remainder (always 0 ≤ r < |b|)
Real-Life Floor Division Examples
Floor division appears naturally whenever you need to split things into groups:
- Packing boxes: You have 250 apples and each box fits 24. How many full boxes? 250 // 24 = 10 boxes (with 10 apples left over).
- Time conversion: 250 minutes equals how many full hours? 250 // 60 = 4 hours (with 10 minutes remaining).
- Currency exchange: You have $1,000 and one item costs $37. How many can you buy? 1000 // 37 = 27 items.
- Tiling a floor: A room is 13 ft wide and each tile is 4 ft. How many whole tiles fit? 13 // 4 = 3 tiles.
- Distributing wages: $500 split equally among 3 workers = $500 // 3 = $166 each (remainder $2).
Floor Division in Programming Languages
Different programming languages handle floor division in different ways:
Python ( // operator)
Python has a dedicated floor division operator // that always rounds toward negative infinity:
13 // 4 → 3 -7 // 2 → -4 # rounds toward -∞ import math math.floor(13 / 4) → 3
JavaScript (Math.floor)
JavaScript uses Math.floor() for floor division:
Math.floor(13 / 4) → 3 Math.floor(-7 / 2) → -4 // rounds toward -∞
C and C++ (integer division)
C and C++ perform truncated division (toward zero) with the / operator on integers — this differs from floor division for negative numbers:
(int)(13 / 4) → 3 // same as floor (int)(-7 / 2) → -3 // truncates toward 0, NOT -4!
Java (integer division)
Java works the same as C — the / operator truncates toward zero:
13 / 4 → 3 -7 / 2 → -3 // not floor division! (int) Math.floor(-7.0 / 2) → -4 // true floor division
Floor Division Symbol
The floor division operation uses the floor function notation ⌊x⌋, which represents the greatest integer less than or equal to x. The floor symbol looks like a square bracket with only the bottom part: ⌊ ⌋.
In Python the symbol for floor division is // (double forward slash). In math, you write it as ⌊a/b⌋ or a div b.
Difference Between Floor Division and Modulo
Floor division and the modulo operation are two sides of the same coin:
- Floor division (q = ⌊a ÷ b⌋) — gives the quotient (how many times b fits into a)
- Modulo (r = a mod b) — gives the remainder (what is left over)
Together they satisfy: a = q × b + r
FAQs
Why is it called "floor" division?
It is named after the floor function in mathematics, which rounds any real number down to the nearest integer. Just like a floor is the lowest surface in a room, the floor function always goes to the lowest whole number.
What is the floor division of two negative numbers?
For two negative numbers, floor division still rounds toward negative infinity. For example: (−13) // (−4) = 3, because −13 ÷ −4 = 3.25, and ⌊3.25⌋ = 3.
Can floor division be applied to decimals?
Yes! Floor division works on any real numbers, not just integers. For example: 7.5 // 2.5 = 3, because 7.5 ÷ 2.5 = 3.0 exactly.
What happens if the divisor is 0?
Division by zero is undefined in mathematics and raises an error in all programming languages (ZeroDivisionError in Python, ArithmeticException in Java, etc.).
How is floor division used in everyday life?
Floor division is used whenever you need to count whole units: number of complete weeks in a month, complete boxes when packing items, complete payments when splitting a bill, number of tiles to buy for a room, and so on.