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.
Inputs
Result
—
Explain my result
Get a plain-English breakdown of your result with practical next steps.
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