How Floor Division Works
Floor division takes a dividend a and a divisor b, computes the exact quotient a ÷ b, and rounds that quotient down to the nearest integer — toward negative infinity, not toward zero. The formula is ⌊a / b⌋, where the ⌊ ⌋ brackets denote the floor function. This calculator also reports the matching remainder and the unrounded exact quotient so you can see exactly how the pieces fit together.
How the calculation works
Enter the dividend and divisor. The calculator first computes the exact division a ÷ b, then applies the floor function to round that value down to the nearest whole number, giving the floor quotient q = ⌊a / b⌋. The remainder is then found from r = a − b × q, which is the amount left over once b has been subtracted from a exactly q times. By construction, the remainder always has the same sign as the divisor (or is zero), and the identity b × q + r = a always holds — the calculator uses this identity as a built-in check on the result.
Common mistakes
- Confusing floor division with truncation: "integer division" in many programming languages (C, Java, JavaScript's
|0) truncates toward zero instead of flooring toward negative infinity. For positive a and b the two agree, but for -17 ÷ 5 truncation gives -3 while floor division gives -4. - Dividing by zero: b = 0 makes a ÷ b undefined, so floor division is undefined there too — there is no integer that "rounds down" from an undefined value.
- Assuming the remainder is always positive when a is negative: with floor division the remainder takes the sign of the divisor, not the dividend, so a negative dividend with a positive divisor still produces a non-negative remainder.
Real-world applications
- Programming and algorithms use floor division to convert a flat index into a (row, column) pair, to bucket values into fixed-size bins, or to implement modular arithmetic and hashing consistently for negative inputs.
- Pagination logic uses floor division to compute how many full pages of items exist, then checks the remainder to decide whether a partial extra page is needed.
- Calendar and time arithmetic uses floor division to convert a total number of minutes, hours, or days into whole larger units (e.g., total minutes ÷ 60 gives whole hours, with the remainder as leftover minutes).
- Number theory and cryptography rely on floor division and its remainder as the building blocks of the Euclidean algorithm and modular arithmetic.