A floor and ceiling calculator finds the floor and the ceiling of any number, its integer part and its fractional part, and does floor division of one number by another with the remainder. Enter your number or the two numbers and press the button. The definitions follow the Wikipedia page on the floor and ceiling functions, and the work is done in your browser. It covers the floor function calculator, the ceiling function calculator and the floor division calculator.
How to use the floor and ceiling calculator
- Choose what you want: floor and ceiling of a number, or floor division.
- Enter the number x, or the dividend a and divisor b.
- Press Calculate.
The floor function
The page defines the floor of x as the largest whole number that is less than or equal to x. It always rounds down, toward minus infinity. So the floor of 2.4 is 2, and the floor of −2.4 is −3, because −3 is the largest whole number not above −2.4. The floor of a whole number is itself. The floor of the number −π is −4. The floor is also written with brackets, as ⌊x⌋, and the equivalent statement is that floor(x) = m exactly when m ≤ x < m + 1.
The ceiling function
The ceiling is the smallest whole number that is greater than or equal to x, so it always rounds up. The ceiling of 2.4 is 3, and the ceiling of −2.4 is −2. For −π, the ceiling is −3. A whole number is its own ceiling. For a number that is not whole, the ceiling is exactly 1 more than the floor.
Integer part and fractional part
The page warns that the phrase integer part can mean cutting the decimals off, which rounds toward zero. For positive numbers this equals the floor, but for negative numbers it equals the ceiling: the integer part of −2.4 is −2, while its floor is −3. The calculator shows both so that you can pick the one your task needs. The fractional part, defined as x minus its floor, is always between 0 and 1. For −2.4 it is 0.6, and for 2.4 it is 0.4.
Floor division
Floor division divides and rounds the quotient down. Many programming languages use it for the // operator. The remainder is then a minus b times the floor of a over b, which is the formula the page gives for the modulo operation: x mod y equals x minus y times the floor of x over y. For 17 divided by 5, the floor quotient is 3 and the remainder is 2. For −7 divided by 3, the floor quotient is −3, since −7/3 is about −2.33, and the remainder is −7 minus 3 × (−3), which is 2. Truncated division rounds toward zero instead, which gives −2 and a remainder of −1. The calculator shows both, together with the ceiling quotient and a remainder that is never negative.
Why the choice of rounding matters
The different rounding rules agree for positive numbers and disagree for negative ones, which is why the same division can give different remainders in different programming languages. When you need a result that behaves the same way for negative inputs, such as in a clock or a repeating schedule, the floor and the Euclidean remainder are the safe choices.
Uses of floor and ceiling
The floor tells you how many complete groups fit in a total, such as how many boxes of 12 you can fill from 100 items: the floor of 100 over 12 is 8. The ceiling tells you how many groups you need to hold everything: the ceiling of 100 over 12 is 9. Both are common in packing, scheduling, pricing in whole units and splitting data into pages.
A worked example with packing
A shop packs eggs in boxes of 12 and has 100 eggs. The floor of 100 divided by 12 is 8, so 8 boxes can be filled completely, and the remainder is 4 eggs. The ceiling is 9, so 9 boxes are needed to hold all the eggs, with the last one only partly full. In the calculator, choose floor division, enter 100 as the dividend and 12 as the divisor, and the floor quotient, the remainder and the ceiling quotient appear together.
Working with decimals and money
The same functions work for decimal numbers. The floor of 7.99 is 7 and the ceiling is 8, and the fractional part of 7.99 is 0.99. To round a price up to the next whole dollar, take the ceiling. To find the whole hours in 7.99 hours, take the floor. Because decimal fractions are stored in binary inside a computer, a value like 0.1 + 0.2 can be a hair below or above 0.3, which can change a floor at an exact boundary, so treat results at exact boundaries with care.
Floor of a negative fraction
For a negative fraction between −1 and 0, such as −0.5, the floor is −1 and the ceiling is 0. This surprises many people who expect the floor to be 0. The fractional part is 0.5, since −0.5 minus −1 is 0.5. Entering −0.5 in the calculator shows the pattern at once.
Common mistakes
- Rounding −2.4 to −2 with the floor. The floor is −3.
- Treating the integer part as the floor. They differ for negative numbers.
- Using the ceiling when you need complete groups. The floor counts complete groups.
- Expecting the remainder to match another language. Check which convention it uses.
- Dividing by zero. There is no result.
What next
Use this often? Add Floor and Ce to your Home screen.
Frequently asked questions
What is a floor and ceiling calculator?
A tool that rounds a number down (floor) or up (ceiling) to a whole number and does floor division with remainders.
What is the floor of −2.4?
−3. The floor is the largest whole number that is less than or equal to the number.
What is the ceiling of 2.4?
3. The ceiling is the smallest whole number that is greater than or equal to the number.
What is floor division?
Division that rounds the quotient down. 17 ÷ 5 gives 3 with remainder 2, and −7 ÷ 3 gives −3 with remainder 2.
How is the floor different from the integer part?
For negative numbers, the integer part cuts toward zero, so −2.4 has integer part −2 but floor −3.
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.