Floor and Ceiling Calculator

Floor and Ceiling Calculator

Enter any number to instantly find its floor (rounded down) and ceiling (rounded up) values.

Accepts decimals, negative numbers and fractions like 17/5.
Floor ⌊ x ⌋
-
Ceiling ⌈ x ⌉
-
Fractional part
-
Your number (blue) shown between its floor and ceiling on the number line.

How to use this calculator

Type a number into the field. You can enter a decimal like 4.7, a negative number like −2.3, or a fraction of two whole numbers like 17/5. Press Calculate.

You will see three results: the floor, the ceiling, and the fractional part. A number line below them shows where your number sits between the two whole numbers. Press Reset to try another number.

This calculator is for the floor and ceiling functions used in math and programming. It is not a room or ceiling-area calculator.

What are the floor and ceiling functions?

The floor function, written ⌊x⌋, gives the greatest whole number that is less than or equal to x. It rounds down. Many textbooks also call it the greatest integer function.

The ceiling function, written ⌈x⌉, gives the smallest whole number that is greater than or equal to x. It rounds up.

If x is already a whole number, the floor and the ceiling both equal x. There is nothing to round.

How to find the floor and ceiling step by step

1. Look at the whole-number part and the decimal part of x.
2. If there is no decimal part, the floor and ceiling both equal x.
3. For a positive number, the floor is the whole-number part. The ceiling is one more.
4. For a negative number, the ceiling is the whole-number part with the decimals dropped. The floor is one less.

The negative case surprises many people. Going down means moving further from zero, so the floor of −2.3 is −3, not −2.

Floor vs ceiling vs rounding vs truncation

These four operations are easy to mix up. The table shows how they differ.

xFloorCeilingRound to nearestTruncate
4.74554
4.24544
−4.7−5−4−5−4
−4.2−5−4−4−4
55555

Truncation just cuts off the decimals. It matches the floor for positive numbers and the ceiling for negative numbers. Rounding to nearest depends on the decimal part. The floor and ceiling ignore it completely.

Useful properties

⌊x⌋ ≤ x ≤ ⌈x⌉ for every number x.
⌈x⌉ − ⌊x⌋ is 1 when x is not a whole number, and 0 when it is.
⌊−x⌋ = −⌈x⌉. For example, ⌊−2.3⌋ = −3 and −⌈2.3⌉ = −3.

Worked examples

x = 4.7
Floor: 4, the greatest whole number at or below 4.7.
Ceiling: 5, the smallest whole number at or above 4.7.
Fractional part: 0.7.
x = −2.3
Floor: −3, because −3 is the greatest whole number at or below −2.3.
Ceiling: −2.
Fractional part: 0.7, because x − ⌊x⌋ = −2.3 − (−3).
x = 17/5
17/5 = 3.4, so the floor is 3 and the ceiling is 4. The fractional part is 0.4.

Here the fractional part means x − ⌊x⌋. That is why it always falls between 0 and 1, even for negative numbers.

Where floor and ceiling are used

Packing and ordering. Use the ceiling when you cannot use part of something. If you have 47 items and each box holds 12, you need ⌈47/12⌉ = 4 boxes. Likewise, 250 items at 20 per page need ⌈250/20⌉ = 13 pages.

Counting complete units. Use the floor when only whole units count. Thirty days contain ⌊30/7⌋ = 4 complete weeks.

Programming. JavaScript has Math.floor and Math.ceil. Python has math.floor and math.ceil. Languages also differ on integer division of negative numbers. In Python, −7 // 2 is −4, because it floors. In C and Java, −7 / 2 is −3, because it truncates.

Common mistakes

Flooring a negative number toward zero. The floor of −2.3 is −3. Moving toward zero gives the ceiling instead.

Confusing the floor with rounding. The floor of 4.9 is 4, even though 4.9 is very close to 5.

Adding 1 to a whole number. The ceiling of 7 is 7. It only moves up when there is a decimal part.

Using the wrong function for the job. Use the ceiling when you must have enough. Use the floor when you count only what is complete.

Frequently asked questions

What are the floor and ceiling of a negative decimal?

For −2.3, the floor is −3 and the ceiling is −2. The floor is the greatest whole number that is still at or below the number. For negatives, that means moving away from zero.

What is the difference between the floor and simple rounding?

Rounding goes to the nearest whole number, so 4.7 becomes 5. The floor always goes down, so 4.7 becomes 4. The ceiling always goes up.

What is the floor or ceiling of a whole number?

Both equal the number itself. The floor and ceiling of 7 are both 7.

What is the greatest integer function?

It is another name for the floor function. Some books write it as [x] instead of ⌊x⌋.

Can I enter a fraction?

Yes. Enter a fraction of two whole numbers, such as 17/5 or −7/2. The calculator divides it and finds the floor and ceiling of the result.

How large a number can I enter?

Up to 1,000,000,000,000,000 in either direction. Computers store numbers with about 15 to 16 digits of precision, so larger values cannot be handled exactly.