terican

Last verified · v1.0

Calculator · math

Floor Division Calculator

Compute ⌊a÷b⌋ instantly. Enter any dividend and divisor to get the floor division result, remainder, and full step-by-step breakdown.

FreeInstantNo signupOpen source

Inputs

Result

Explain my result

0/3 free

Get a plain-English breakdown of your result with practical next steps.

Result

The formula

How the
result is
computed.

What Is Floor Division?

Floor division computes the largest integer less than or equal to the exact quotient of two numbers. Given a dividend a and a nonzero divisor b, the result is written ⌊a ÷ b⌋. The floor function ⌊x⌋ returns the greatest integer n satisfying n ≤ x < n+1 — it always rounds toward negative infinity, never toward zero. This distinction is critical when working with negative numbers.

Understanding the Variables

  • Dividend (a): The number being divided. Accepts any integer or decimal value, positive or negative. Acts as the numerator of the quotient.
  • Divisor (b): The number to divide by. Must be nonzero — division by zero is undefined across all number systems. Acts as the denominator.
  • Operation: Selects which integer-division operation to apply — floor division ⌊a/b⌋, ceiling division ⌈a/b⌉, truncated division (round toward zero), or modulo remainder. Each produces a different integer result for negative inputs.

Step-by-Step Derivation

Every floor division calculation follows three deterministic steps:

  • Step 1 — Divide: Compute the real-valued quotient q = a / b using standard arithmetic.
  • Step 2 — Apply the floor: Find ⌊q⌋, the largest integer that does not exceed q. For positive q this trims the decimal; for negative q this decrements the integer part by one when any fractional part exists.
  • Step 3 — Verify with the modulo identity: Confirm that a = b × ⌊a/b⌋ + (a mod b), where the remainder a mod b carries the same sign as b.

Worked Examples

Positive Dividend and Divisor

17 ÷ 5: 17 / 5 = 3.4 → ⌊3.4⌋ = 3. The fractional part 0.4 is discarded by rounding down. Remainder: 17 − 5 × 3 = 2.

20 ÷ 4: 20 / 4 = 5.0 → ⌊5.0⌋ = 5. An exact quotient needs no adjustment; the remainder is 0.

100 ÷ 7: 100 / 7 ≈ 14.286 → ⌊14.286⌋ = 14. Remainder: 100 − 7 × 14 = 2.

Negative Dividend, Positive Divisor

−7 ÷ 2: −7 / 2 = −3.5 → ⌊−3.5⌋ = −4. The floor rounds toward negative infinity, so −4 (not −3) is correct. Many programmers expect −3 because they confuse floor with truncation.

−20 ÷ 3: −20 / 3 = −6.667 → ⌊−6.667⌋ = −7. Remainder: −20 − 3 × (−7) = 1.

Positive Dividend, Negative Divisor

7 ÷ (−2): 7 / −2 = −3.5 → ⌊−3.5⌋ = −4. The sign of the divisor drives the direction of rounding for any non-integer quotient.

Negative Dividend, Negative Divisor

−7 ÷ (−2): −7 / −2 = 3.5 → ⌊3.5⌋ = 3. Two negatives produce a positive quotient, so the result behaves like the positive case.

Floor Division vs. Truncation Division

Truncation (used in C, Java, JavaScript, and many older languages) discards the fractional part by rounding toward zero, yielding trunc(−3.5) = −3. Floor division always rounds toward negative infinity, yielding ⌊−3.5⌋ = −4. For non-negative quotients the two operations are identical; for negative quotients they diverge by exactly 1. Python's // operator implements true floor division for both integers and floats, as documented in the Kennesaw State University CSE1321L Python curriculum. The Sage mathematical software system also uses floor division semantics for its integer operators, as detailed in the SDSU Sage as a Calculator tutorial.

The Modulo Identity

Floor division and the modulo operation are mathematically complementary. The identity a = b × ⌊a/b⌋ + (a mod b) holds for all real a and nonzero b. When floor division is used, the remainder a mod b always carries the same sign as b, not a. Example: −7 = 2 × (−4) + 1, so −7 mod 2 = 1 (positive, matching the sign of b = 2). This sign consistency makes floor division the preferred basis for modular arithmetic in cryptography and number theory — C-style truncation produces remainders that can be negative, which breaks many modular algorithms.

Real-World Applications

  • Pagination: Total display pages = ⌊item count / page size⌋ + (1 if remainder > 0). For 103 items at 10 per page: ⌊103/10⌋ + 1 = 11 pages.
  • Time conversion: Minutes from seconds = ⌊total seconds / 60⌋; hours = ⌊minutes / 60⌋. Converting 3 661 seconds: 61 minutes and 1 second.
  • Tile and grid layouts: Complete rows = ⌊total tiles / tiles per row⌋ determines how many full rows fit before overflow.
  • Load balancing: Base tasks per worker = ⌊total tasks / worker count⌋; the first (total mod workers) workers receive one extra task.
  • Binary search midpoint: mid = ⌊(low + high) / 2⌋ avoids overflow and guarantees an integer index in array searches.
  • Cryptographic modular arithmetic: RSA key generation and most hash functions rely on floor-division-based modular reduction to keep values within defined integer ranges.

Methodology and Sources

This calculator implements the floor function as formally defined by the George Washington University SEAS Module 6: Real Numbers, which establishes ⌊x⌋ as the unique integer n satisfying n ≤ x < n+1. Integer-division operator behavior across Python, Sage, and related environments is documented in the Kennesaw State University CSE1321L Python assignment guide. All computations use IEEE 754 double-precision arithmetic to ensure results are accurate for operands up to 2^53.

Reference

Frequently asked questions

What is floor division and how does it differ from regular division?
Floor division divides two numbers and rounds the quotient down to the nearest integer toward negative infinity. Regular division returns a decimal result (7 ÷ 2 = 3.5), while floor division returns the integer 3. For negative quotients the difference is more pronounced: −7 ÷ 2 gives −4 under floor division, not −3 or −3.5, because −4 is the greatest integer that does not exceed −3.5.
Why does floor division of a negative number round down instead of toward zero?
The floor function is defined as the greatest integer not exceeding the quotient. For −3.5, the integers on either side are −4 and −3. Since −4 ≤ −3.5 and −3 &gt; −3.5, the floor is −4. Rounding toward zero (truncation, which would give −3) is a mathematically distinct operation. Python, Sage, and this calculator use true floor semantics to keep the paired modulo remainder non-negative and consistent with the divisor sign.
What is the difference between floor division and truncation division?
Both produce integers, but they diverge on negative quotients. Truncation rounds toward zero: trunc(−3.5) = −3. Floor division rounds toward negative infinity: ⌊−3.5⌋ = −4. For positive quotients both operations give identical results. C, Java, and JavaScript use truncation for their integer division operators; Python's // operator and this calculator implement true floor division, which is the standard in most modern mathematical software.
How does Python's // operator implement floor division?
Python's // operator applies the floor function to the exact real-valued quotient for both integer and float operands. Examples: 7 // 2 = 3, −7 // 2 = −4, and 7.5 // 2 = 3.0 (a float). The companion % operator returns a remainder that always shares the sign of the divisor, satisfying the invariant a == (a // b) * b + (a % b) for every nonzero b — a guarantee that C-style truncation division cannot provide.
What is the modulo identity and how does it relate to floor division?
The modulo identity states a = b × ⌊a/b⌋ + (a mod b) for all real a and nonzero b. When floor division is used, the remainder a mod b is always non-negative when b is positive and always non-positive when b is negative — it carries the sign of b, not a. Concrete example: −7 = 2 × (−4) + 1, so −7 mod 2 = 1. This sign consistency is essential for modular arithmetic used in cryptographic algorithms and hash functions.
What are the most common real-world applications of floor division?
Floor division solves practical problems across many domains: pagination counts total pages as ⌊items / page_size⌋; time conversion derives minutes as ⌊seconds / 60⌋ and hours as ⌊minutes / 60⌋; grid layouts compute full rows as ⌊total_tiles / row_width⌋; load-balancing assigns ⌊tasks / workers⌋ base tasks per worker; binary search computes safe midpoints as ⌊(low + high) / 2⌋; and RSA cryptography uses floor-division-based modular reduction throughout key generation and encryption.