The Floor and Ceiling Function Calculator returns the floor ⌊x⌋, ceiling ⌈x⌉, nearest-integer rounding, truncation and fractional part of any number, including negatives. A second tab performs floor division, ceiling division and the modulo (remainder) of two numbers.
Floor and Ceiling Function Calculator
Floor ⌊x⌋, ceiling ⌈x⌉, rounding, truncation and fractional part of any number — plus floor division and modulo.
The floor is the greatest integer less than or equal to x; the ceiling is the smallest integer greater than or equal to x. For positive numbers floor and truncation agree, but for negative numbers they differ — the most common source of confusion.
Formula
- Floor: ⌊x⌋ = greatest integer ≤ x
- Ceiling: ⌈x⌉ = smallest integer ≥ x
- Round: nearest integer, with halves rounded up (toward +∞)
- Truncate: drop the decimals (round toward 0)
- Fractional part: {x} = x − ⌊x⌋ (always from 0 up to, but not including, 1)
- Floor division: ⌊a ÷ b⌋; modulo: a mod b = a − b × ⌊a ÷ b⌋
How the Calculation Works
Step 1: Locate x between two consecutive integers.
Step 2: Floor takes the lower one, ceiling the upper one.
Step 3: For division, floor the exact quotient; the remainder is what’s left.
Example Calculation
x = −3.7
- ⌊−3.7⌋ = −4
- ⌈−3.7⌉ = −3
- Round = −4
- Truncate = −3
- {−3.7} = −3.7 − (−4) = 0.3
17 ÷ 5
- Exact = 3.4; floor division = 3; ceiling division = 4
- 17 mod 5 = 17 − 5 × 3 = 2
−17 ÷ 5
Exact = −3.4; floor division = −4; −17 mod 5 = −17 − 5 × (−4) = 3
Comparison Table
| x | Floor | Ceiling | Round | Truncate |
|---|---|---|---|---|
| 2.3 | 2 | 3 | 2 | 2 |
| 2.5 | 2 | 3 | 3 | 2 |
| −2.3 | −3 | −2 | −2 | −2 |
| −2.5 | −3 | −2 | −2 | −2 |
| 4 | 4 | 4 | 4 | 4 |
Where Floor and Ceiling Are Used
- Ceiling for “how many do I need” — boxes, cans, tiles or pages always round up.
- Floor for “how many fit” — whole items that fit into a length or budget.
- Modulo for clock arithmetic, repeating patterns and checking divisibility.
Frequently Asked Questions
What is the floor of a negative number?
The next integer down: ⌊−2.3⌋ = −3.
What is the difference between floor and truncate?
They match for positive numbers; for negatives, floor goes down and truncate goes toward zero.
What is the ceiling of 4.1?
5.
Why is −17 mod 5 equal to 3?
With floor division the remainder takes the sign of the divisor: −17 = 5 × (−4) + 3.
How do I compute ceiling division without a ceiling function?
For positive integers, ⌈a ÷ b⌉ = ⌊(a + b − 1) ÷ b⌋.
Is this how Python’s // and % work?
Yes — Python uses floor division and a remainder with the sign of the divisor.
