Floor Division Calculator — ⌊a ÷ b⌋ with Remainder
Compute the floor division quotient ⌊a ÷ b⌋ and the corresponding remainder. Floor division always rounds toward negative infinity — this differs from truncation division for negative numbers and matches the behaviour of Python's // operator.
Greatest integer q such that b × q ≤ a
Divide a by b (exact)
Apply floor (round toward −∞)
Remainder
Verification
- 1
Exact quotient a ÷ b
17 ÷ 5 = 3.4 - 2
Apply floor ⌊·⌋ — round toward −∞
⌊3.4⌋ = 3 - 3
Remainder r = a − b × q
17 − 5 × 3 = 2
How does this calculator work?
Floor division: q = ⌊a / b⌋ (round toward −∞), r = a − b × q, verify b × q + r = a. Positive numbers: same as truncation. Negative quotients differ: ⌊−7/2⌋ = −4 (floor) vs −3 (truncation). Remainder always has the same sign as the divisor. Used by Python //, Haskell div, and Ruby div.
Formula
How this is calculated
Floor division divides two numbers and rounds the exact quotient toward negative infinity (−∞) to obtain an integer quotient q. The remainder r is then defined as r = a − b × q, so that b × q + r = a exactly. For positive operands, floor division and truncation division give the same result: ⌊17 / 5⌋ = ⌊3.4⌋ = 3, remainder 2.
For negative numbers the two operations differ. Consider −7 ÷ 2: the exact quotient is −3.5. Floor division rounds toward −∞ giving q = −4 and r = −7 − 2 × (−4) = 1 (remainder positive, same sign as the divisor). Truncation rounds toward 0 giving q = −3 and r = −7 − 2 × (−3) = −1 (remainder negative, same sign as the dividend). Python's // operator, Haskell's div and Ruby's div all use floor division. C, Java, JavaScript and Python's int() all use truncation division.
The floor-division remainder r = a − b × ⌊a/b⌋ is also called the true modulo or Euclidean modulo. It always has the same sign as the divisor b. The property b × q + r = a holds for any finite non-zero b, making it easy to verify the result.
Frequently asked questions
For positive numbers they agree. For negative quotients they diverge: floor division rounds toward −∞ (further from zero), while truncation rounds toward 0 (closer to zero). For example, ⌊−7 / 2⌋ = −4 (floor) but trunc(−7 / 2) = −3 (truncation). The remainders also differ in sign: floor gives a remainder with the same sign as the divisor; truncation gives one with the same sign as the dividend.
Python's // operator performs floor division for both integers and floats. Haskell's div, Ruby's Integer#div and Dart's ~/ also use floor semantics. Most other languages (C, Java, JavaScript, C++) use truncation division by default. Python's % operator is the corresponding floor-division remainder (true modulo), while C's % is the truncation remainder.
The identity b × q + r = a always holds, regardless of signs. This lets you verify any division result: multiply the divisor by the quotient, add the remainder, and you should recover the dividend exactly. For floor division the remainder r always satisfies 0 ≤ r < |b| when b > 0, and |b| < r ≤ 0 when b < 0.
Also known as
TG we-Calculate Editorial Team. (2026). Floor Division Calculator — ⌊a ÷ b⌋ with Remainder [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/floor-division-calculator
TG we-Calculate Editorial Team. "Floor Division Calculator — ⌊a ÷ b⌋ with Remainder." TG we-Calculate. 2026. https://we-calculate.com/calculator/floor-division-calculator.
TG we-Calculate Editorial Team, "Floor Division Calculator — ⌊a ÷ b⌋ with Remainder," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/floor-division-calculator
@misc{wecalculate_floor_division_calculator, title = {Floor Division Calculator — ⌊a ÷ b⌋ with Remainder}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/floor-division-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
