Skip to content

Floor Division Calculator

Updated:

This floor division calculator divides two numbers and rounds the result down to the nearest whole number. Enter a dividend and a non-zero divisor to get the floored quotient, useful in programming, pagination, and integer math.

Perform Integer (Floor) Division Online

Input Fields
a
Enter the number to be divided
b
Enter the number by which to divide (must be non-zero)
If enabled, the result will update automatically when you change any value.

Floor Division Formula

Formula
\[ a \mathbin{\mathrm{div}} b = \left\lfloor \frac{a}{b} \right\rfloor \]

Where:

  • \(a\) — the dividend, the number being divided
  • \(b\) — the divisor, the number you divide by (\(b \neq 0\))
  • \(\lfloor \cdot \rfloor\) — the floor function, which rounds a real number down to the greatest integer less than or equal to it

The formula states that floor division equals the ordinary quotient \(a / b\) rounded down to the nearest integer. In many programming languages this operation is written with the operator \(a \mathbin{//} b\), as in Python.

Floor Division – Calculation Example

Example: you want to split 10 items evenly into groups of 3 and need to know how many complete groups you can make.

\[ \frac{10}{3} = 3.\overline{3} \quad \Rightarrow \quad \left\lfloor \frac{10}{3} \right\rfloor = 3 \]

Result: \(10 \mathbin{//} 3 = 3\). Three complete groups can be formed, with 1 item left over (the remainder \(10 \bmod 3 = 1\)).

With a negative dividend: \(-7 \mathbin{//} 2 = \lfloor -3.5 \rfloor = -4\), because floor division always rounds down, not toward zero.

How to use the calculator

  1. Enter the Dividend (a) — the number you want to divide. The default value is 10.
  2. Enter the Divisor (b) — the number to divide by. It must be non-zero; the calculator rejects a divisor of 0. The default value is 3.
  3. Read the Floor Division Result — the quotient of the two numbers rounded down to the nearest whole number.

The calculator updates instantly as you change either input, and it accepts negative dividends as well as positive ones.

What is floor division?

Floor division is a form of integer division that returns the largest whole number less than or equal to the true quotient. Ordinary division of 10 by 3 gives 3.333…, but floor division discards the fractional part by rounding down, giving 3. This differs from simple truncation when negative numbers are involved: truncating \(-7/2 = -3.5\) toward zero gives \(-3\), while flooring it gives \(-4\).

The operation appears throughout mathematics and computing. In Python it is the // operator; in many other languages (C, Java, JavaScript) integer division of positive numbers behaves the same way, though negative operands are often truncated toward zero instead of floored. Related concepts include the Division operation itself and the modulo operation, since every division with a remainder satisfies \(a = b \lfloor a/b \rfloor + (a \bmod b)\).

Floor division matters whenever only whole units make sense. If you have 10 apples and pack them into boxes of 3, you can fill exactly \(\lfloor 10/3 \rfloor = 3\) boxes. If a web page shows 10 results per page, \(\lfloor n/10 \rfloor\) tells you how many complete pages \(n\) items fill — the basis of pagination logic in nearly every website and database query.

Common applications

  • Pagination: computing the number of full pages or the index of the page containing a given item.
  • Indexing and slicing: converting a linear index into row/column coordinates, e.g. row = index // columns.
  • Time conversions: converting 130 seconds into minutes uses \(\lfloor 130/60 \rfloor = 2\) minutes with 10 seconds remaining.
  • Scheduling and grouping: splitting people into teams or items into batches of fixed size.
  • Number theory: floor division underpins the multiplicative inverse modulo, the Chinese Remainder Theorem, and other calculations that rely on quotients and remainders.
  • Loop iterations: algorithms such as binary search, tree traversals, and divide-and-conquer use halving via \(\lfloor n/2 \rfloor\) at every step.

Assumptions and limitations

  • Division by zero is undefined: the calculator shows an error if the divisor is 0, just as ordinary division does.
  • Rounding direction: the result is always rounded down (toward negative infinity), not toward zero. This matches Python's // operator, but differs from integer division in C and Java, which truncate toward zero for negative operands.
  • No remainder shown: this tool returns only the floored quotient. To also get the leftover amount, compute the remainder \(a - b \cdot (a \mathbin{//} b)\) — for the default example, \(10 - 3 \cdot 3 = 1\).
  • Fractional inputs: although typical use involves whole numbers, the calculator accepts decimal values; the quotient is still floored to a whole number.

For plain division with decimals, use the Division calculator; for the other basic operations, see the Multiplication and Subtraction calculators.

Frequently Asked Questions

How do I calculate floor division by hand?

Divide the two numbers normally, then round the result down to the nearest whole number. For example, \(17 \div 5 = 3.4\), and rounding down gives 3. Always round toward negative infinity, never up: even 3.01 becomes 3. If the division is exact, such as \(12 \div 4 = 3\), the answer is already a whole number and nothing changes.

Why is -7 // 2 equal to -4 and not -3?

The floor function moves down the number line, and \(-4 < -3.5 < -3\). Since \(-7 \div 2 = -3.5\), the largest integer less than or equal to it is \(-4\). Truncation toward zero would give \(-3\), but that is a different operation. This trips up programmers: C, Java, and JavaScript truncate, while Python, Ruby, and R floor.

What is the difference between floor division and modulo?

Floor division tells you how many whole times the divisor fits into the dividend; modulo tells you what is left over. They are linked by the identity \(a = b \cdot \lfloor a/b \rfloor + (a \bmod b)\). Example: 10 items in boxes of 3 give 3 full boxes and 1 leftover, because \(10 = 3 \cdot 3 + 1\).

Does floor division work with decimal or fractional inputs?

Yes. The calculator accepts decimals, and the rule stays the same: compute the ordinary quotient, then round down. For instance, \(7.5 \div 2 = 3.75\), so the floored result is 3. With \(-7.5 \div 2 = -3.75\) the result is \(-4\), again rounding down, not toward zero.

How is floor division used for pagination?

To find which page an item is on, divide the item's zero-based index by the page size using floor division. With 10 items per page, item index 25 sits on page \(25 \div 10 = 2\) (the third page, counting from zero). To count pages for \(n\) items, use \(\lfloor (n + 9) \div 10 \rfloor\), since a partial final page still counts as a full page.

What happens if the divisor is negative?

The division works, and the quotient is still floored. For example, \(10 \div -3 = -3.\overline{3}\), and flooring gives \(-4\), while \(-10 \div 3 = -3.\overline{3}\) also floors to \(-4\). Note that in Python the sign of the remainder follows the divisor, so \(10 \bmod -3 = -2\), which surprises people who expect a positive leftover.

What is a common mistake when using floor division?

The most frequent error is assuming it rounds toward zero or drops the decimal point. With negative numbers these give different answers: \(-7 \div 2\) is \(-4\) when floored but \(-3\) when truncated. Another mistake is forgetting the remainder exists — floor division alone does not tell you whether the division was exact.

Leave a Reply

Your email address will not be published. Required fields are marked *