Floor and Ceiling

Learning goals

  • Take the floor as the greatest integer at or below xx
  • Round down on negatives, not toward zero
  • Draw the staircase with the right open and closed ends
  • Define the fractional part as x−⌊x⌋x - \lfloor x \rfloor
  • Choose ceiling for containers and floor for full groups

What the floor and ceiling are

The floor of xx, written ⌊x⌋\lfloor x \rfloor, is the greatest integer that is less than or equal to xx. The ceiling of xx, written ⌈x⌉\lceil x \rceil, is the least integer that is greater than or equal to xx. The bent brackets are a memory aid: the floor’s brackets point down toward the ground, the ceiling’s point up.

Try a few. Since 3.73.7 sits between 33 and 44, the integers at or below it are 3,2,1,…3, 2, 1, \dots, and the greatest is 33, so ⌊3.7⌋=3\lfloor 3.7 \rfloor = 3. The integers at or above 3.73.7 are 4,5,6,…4, 5, 6, \dots, and the least is 44, so ⌈3.7⌉=4\lceil 3.7 \rceil = 4. When the input is already an integer, like 55, it is itself the greatest integer at or below and the least integer at or above, so ⌊5⌋=⌈5⌉=5\lfloor 5 \rfloor = \lceil 5 \rceil = 5.

For 3.73.7, the two neighboring integers give 3≤3.7<43\le3.7<4. In general, if n=⌊x⌋n=\lfloor x\rfloor, then

n≤x<n+1.n\le x<n+1.

The floor nn is at or below xx. The next integer, n+1n+1, is larger than nn; since nn is the greatest integer at or below xx, n+1n+1 must be above xx. Only one integer fits both bounds. An integer above nn is at least n+1n+1, too large to be at or below xx. For an integer m<nm<n, m+1≤n≤xm+1\le n\le x, so x<m+1x<m+1 fails. Thus any integer kk satisfying k≤x<k+1k\le x<k+1 is the floor.

The same reasoning, applied to the least integer at or above xx, gives the mirror statement for the ceiling:

⌈x⌉−1<x≤⌈x⌉.\lceil x \rceil - 1 < x \le \lceil x \rceil.

An integer is its own floor and ceiling, as we saw with 55. In symbols,

⌊x⌋=⌈x⌉=x(x an integer).\lfloor x \rfloor = \lceil x \rceil = x \qquad (x \text{ an integer}).

A non-integer lies strictly between consecutive integers nn and n+1n+1. Its floor is nn, and its ceiling is n+1n+1. Therefore

⌈x⌉=⌊x⌋+1(x not an integer).\lceil x \rceil = \lfloor x \rfloor + 1 \qquad (x \text{ not an integer}).

So the ceiling and floor are equal exactly on the integers, and exactly one apart everywhere else.

Worked example 1 Evaluate six floors and ceilings

Read each one off the number line by finding the integer that fits against the input.

For ⌊6.2⌋\lfloor 6.2 \rfloor, the input sits between 66 and 77, and the greatest integer at or below is 66, so ⌊6.2⌋=6\lfloor 6.2 \rfloor = 6. For ⌈6.2⌉\lceil 6.2 \rceil, the least integer at or above is 77, so ⌈6.2⌉=7\lceil 6.2 \rceil = 7.

For ⌊9⌋\lfloor 9 \rfloor, the input is already an integer, so ⌊9⌋=⌈9⌉=9\lfloor 9 \rfloor = \lceil 9 \rceil = 9.

For ⌈0.1⌉\lceil 0.1 \rceil, the input is just above 00, so the least integer at or above is 11, giving ⌈0.1⌉=1\lceil 0.1 \rceil = 1, while ⌊0.1⌋=0\lfloor 0.1 \rfloor = 0.

⌊6.2⌋=6,⌈6.2⌉=7,⌊9⌋=9,⌈0.1⌉=1.\lfloor 6.2 \rfloor = 6, \quad \lceil 6.2 \rceil = 7, \quad \lfloor 9 \rfloor = 9, \quad \lceil 0.1 \rceil = 1.

Every answer is an integer: the floor and ceiling only ever return integers, negative ones included.

Rounding down is not the same as chopping off the decimal

“Round down” means move left on the number line, toward smaller values. For negative numbers, that differs from deleting the decimal part.

Take x=−2.3x = -2.3. It sits between −3-3 and −2-2. The integers at or below −2.3-2.3 are −3,−4,−5,…-3, -4, -5, \dots, and the greatest of them is −3-3, so

⌊−2.3⌋=−3.\lfloor -2.3 \rfloor = -3.

The answer −2-2 is wrong, because −2-2 is greater than −2.3-2.3, so −2-2 is not “at or below” −2.3-2.3 at all. Chopping the decimal off −2.3-2.3 would give −2-2, but that is rounding toward zero, not rounding down. The floor always rounds toward negative infinity. The ceiling goes the other way: the least integer at or above −2.3-2.3 is −2-2, so ⌈−2.3⌉=−2\lceil -2.3 \rceil = -2. On the picture below, the floor is simply the tick to the left and the ceiling is the tick to the right.

Floor and ceiling of negative 2.3 on the number lineThe point negative 2.3 lies between negative 3 and negative 2; its floor is negative 3, the integer to its left, and its ceiling is negative 2, the integer to its right.-4-3-2-101-2.3floor = -3ceiling = -2
Floor and ceiling of a negative number. The point x equals negative 2.3 sits between the integers negative 3 and negative 2. The floor is the nearest integer to the left, negative 3, and the ceiling is the nearest integer to the right, negative 2. Rounding down moves left toward negative 3, which is why the floor is not the negative 2 you would get by dropping the decimal.

Worked example 2 Evaluate floors and ceilings of negative inputs

Handle each one by asking which integer sits to the left (for the floor) and which sits to the right (for the ceiling).

The value −0.5-0.5 lies between −1-1 and 00. The greatest integer at or below is −1-1 and the least integer at or above is 00, so ⌊−0.5⌋=−1\lfloor -0.5 \rfloor = -1 and ⌈−0.5⌉=0\lceil -0.5 \rceil = 0.

The value −7.2-7.2 lies between −8-8 and −7-7. Rounding down goes to −8-8 and rounding up goes to −7-7:

⌊−7.2⌋=−8,⌈−7.2⌉=−7.\lfloor -7.2 \rfloor = -8, \qquad \lceil -7.2 \rceil = -7.

For the integer input −4-4, both functions return it unchanged, ⌊−4⌋=⌈−4⌉=−4\lfloor -4 \rfloor = \lceil -4 \rceil = -4. Notice the pattern for the non-integers: the floor and the ceiling of −0.5-0.5 and of −7.2-7.2 are always one apart, exactly as ⌈x⌉=⌊x⌋+1\lceil x \rceil = \lfloor x \rfloor + 1 predicted.

Check your understanding

Evaluate ⌊−3.2⌋\lfloor -3.2 \rfloor.

Answer choices

The graphs are staircases

Start with 2≤x<32\le x<3. Every input in that interval has floor 22, so draw a horizontal step at height 22. Include (2,2)(2,2) with a filled dot, but leave (3,2)(3,2) open: at x=3x=3, the floor is already 33.

For any integer nn, the same rule gives height nn on n≤x<n+1n\le x<n+1. Each floor step is closed on the left and open on the right. At the next integer the height increases by one, creating a staircase.

The staircase graph of y equals the floor of xHorizontal steps closed with a filled dot on the left and open with a hollow circle on the right, rising one unit at each integer, so the range is the integers and the domain is all real numbers.xy-3-2-112340321-1-2-3y = ⌊x⌋
The graph of y equals the floor of x is a staircase. On each interval from an integer n up to n plus 1, the floor holds the constant height n, drawn as a horizontal step. The left end is closed (filled) because the floor equals n there, and the right end is open (hollow) because the value jumps up by one at the next integer. The domain is every real number and the range is the integers.

For the ceiling, 1<x≤21<x\le2 gives height 22. Include (2,2)(2,2) and leave (1,2)(1,2) open because ⌈1⌉=1\lceil1\rceil=1. In general, height nn belongs to n−1<x≤nn-1<x\le n, so ceiling steps are open on the left and closed on the right. The endpoint pattern is the reverse of the floor’s.

The staircase graph of y equals the ceiling of xHorizontal steps open with a hollow circle on the left and closed with a filled dot on the right, rising one unit at each integer, with the opposite endpoint pattern to the floor staircase.xy-3-2-112304321-1-2y = ⌈x⌉
The graph of y equals the ceiling of x, with the opposite endpoint pattern to the floor staircase. Each step holds the height n across the interval that ends at x equals n, so the closed (filled) end is on the right and the open (hollow) end is on the left. The domain is again every real number and the range is the integers.

Both graphs pass the vertical line test (each input has one output), so they really are functions. Both accept every real number, so the domain of each is all real numbers. And every output is an integer, with each integer height actually reached, so the range of each is the integers. The steps never connect with vertical lines, because the function does not take the in-between values during a jump. The open and closed dots show which step each integer input belongs to.

Worked example 3 Solve ⌊x⌋=−3\lfloor x \rfloor = -3 and ⌈x⌉=2\lceil x \rceil = 2

Each equation asks for the whole strip of inputs that a single step covers, so read it straight off the defining inequality.

For ⌊x⌋=−3\lfloor x \rfloor = -3, the floor equals −3-3 exactly on the step that starts at −3-3:

−3≤x<−2.-3 \le x < -2.

Every xx from −3-3 (included) up to −2-2 (not included) has floor −3-3, and nothing else does.

For ⌈x⌉=2\lceil x \rceil = 2, the ceiling equals 22 exactly on the step that ends at 22:

1<x≤2.1 < x \le 2.

Here the left end 11 is excluded and the right end 22 is included, matching the open-left, closed-right shape of the ceiling staircase.

Check your understanding

Which values of xx satisfy ⌈x⌉=−1\lceil x \rceil = -1?

Answer choices

The fractional part

Subtracting the floor from a number strips away the whole part and leaves only what is left over. That leftover is the fractional part of xx, written {x}\{x\}:

{x}=x−⌊x⌋.\{x\} = x - \lfloor x \rfloor.

It is always at least 00 and always less than 11, and the defining inequality shows exactly why. Start from n≤x<n+1n \le x < n + 1 with n=⌊x⌋n = \lfloor x \rfloor and subtract nn from every part:

0≤x−n<1,that is0≤{x}<1.0 \le x - n < 1, \qquad \text{that is} \qquad 0 \le \{x\} < 1.

For a positive number this matches intuition: {3.7}=3.7−3=0.7\{3.7\} = 3.7 - 3 = 0.7, the digits after the decimal point. For a negative input, remember that the floor rounds down. Because ⌊−2.3⌋=−3\lfloor -2.3 \rfloor = -3,

{−2.3}=−2.3−(−3)=0.7.\{-2.3\} = -2.3 - (-3) = 0.7.

The fractional part is the distance above the floor: −2.3-2.3 is 0.70.7 above −3-3. The visible 0.30.3 is instead its distance below −2-2, the ceiling. At an integer, the input equals its floor, so the fractional part is zero: {5}=5−5=0\{5\}=5-5=0. Only integers give zero.

Worked example 4 Compute {5.8}\{5.8\} and {−1.2}\{-1.2\}

Use {x}=x−⌊x⌋\{x\} = x - \lfloor x \rfloor, taking care with the floor of the negative input.

For 5.85.8, the floor is 55, so the leftover is the visible decimal part:

{5.8}=5.8−⌊5.8⌋=5.8−5=0.8.\{5.8\} = 5.8 - \lfloor 5.8 \rfloor = 5.8 - 5 = 0.8.

For −1.2-1.2, the floor rounds down to −2-2, not −1-1, so

{−1.2}=−1.2−⌊−1.2⌋=−1.2−(−2)=0.8.\{-1.2\} = -1.2 - \lfloor -1.2 \rfloor = -1.2 - (-2) = 0.8.

Both land in [0,1)[0, 1). The numbers −1.2-1.2 and 5.85.8 are exactly 77 apart, a whole number of steps, so they sit the same distance above their floors: both have fractional part 0.80.8.

Check your understanding

Compute the fractional part {−1.25}\{-1.25\}.

Answer choices

A ceiling can also be written using a floor: ⌈x⌉=−⌊−x⌋\lceil x\rceil=-\lfloor-x\rfloor.

Where floor and ceiling show up

Floor and ceiling answer two different counting questions: how many complete groups can you make, and how many containers hold everything?

Use a ceiling when every leftover still needs a full container. If 5353 students travel in vans that seat 1212, then 53÷12=4.41…53 \div 12 = 4.41\ldots vans’ worth of seats are needed. But you cannot send a fractional van, and the 55 students left over after four full vans still need one more. So the number of vans is ⌈53/12⌉=5\lceil 53 / 12 \rceil = 5. Buses for a crowd, pages for a list, and boxes for a shipment all work this way.

Use a floor when leftovers are discarded and you only count what is complete. From those same 5353 students you can fill ⌊53/12⌋=4\lfloor 53 / 12 \rfloor = 4 vans completely. The amount left over is what the full groups do not use,

53−12×⌊53/12⌋=53−48=5,53 - 12 \times \lfloor 53 / 12 \rfloor = 53 - 48 = 5,

which is the same fractional-part idea from before, now scaled up by the group size. Full crates from a harvest, whole dollars from a pile of change, and complete laps around a track are all floors.

You can see both answers in one picture. Lay nn objects into rows that hold cc each, with nn a nonnegative integer and cc a positive integer: the number of complete rows is ⌊n/c⌋\lfloor n/c \rfloor, and the number of rows needed to hold everything, counting a partly filled last row, is ⌈n/c⌉\lceil n/c \rceil. Try it below.

Start at 1010 dots in rows of 44. Two rows fill and two dots are left hollow, so ⌊10/4⌋=2\lfloor 10/4 \rfloor = 2 while ⌈10/4⌉=3\lceil 10/4 \rceil = 3. Any leftover from one dot to three would force that same extra row, since the row width is four. Now widen the rows to 55: the same 1010 dots fill two rows exactly with nothing hollow, so floor and ceiling agree at 22. Narrow the rows to 33 instead and one dot is hollow again, splitting the answers to 33 and 44. Change the row width a few more times and watch for the pattern: the two functions differ by exactly one whenever a dot is left hollow, and are equal whenever none is.

Reading the floor and the ceiling off the rows

10 dots in rows of 4 make 2 full rows with 2 dots left over. So the floor of 10/4 is 2, and the ceiling is 3. Dots laid out in equal rows, filling from the top left. Dots that do not complete a row are drawn hollow. Use the controls below the figure to change the number of dots or the row width.
Dots Rows of

10 dots in rows of 4 make 2 full rows with 2 dots left over. So the floor of 10/4 is 2, and the ceiling is 3.

Dots laid into equal rows from the top left, with any dot that cannot complete a row drawn hollow. The number of solid rows is the floor of the count divided by the row width, and the number of rows holding any dot at all is its ceiling, so the two differ by one exactly when a dot is left hollow.

Worked example 5 Plan a field trip for 150150 students

Each bus holds 4040 students. First find how many buses are needed. Dividing gives 150/40=3.75150 / 40 = 3.75, and the 3030 students beyond three full buses still need to ride, so round up with a ceiling:

⌈150/40⌉=⌈3.75⌉=4 buses.\lceil 150 / 40 \rceil = \lceil 3.75 \rceil = 4 \text{ buses}.

Now suppose you instead want only the buses you can fill completely. That is a floor:

⌊150/40⌋=3 full buses,\lfloor 150 / 40 \rfloor = 3 \text{ full buses},

and the students left standing are 150−40×3=30150 - 40 \times 3 = 30, who fill the fourth bus only part way. The two answers differ by one whole bus, which is the usual gap between a ceiling and a floor when the division does not come out even.

Check your understanding

A bakery packs muffins into boxes of 66. There are 5050 muffins to pack, and every muffin needs to go in some box. How many boxes are needed?

Answer choices

Common mistakes

Practice

Multiple Choice Questions (MCQ)

Progressively harder sets of questions. Each opens on its own page.

Core practice

Practice problems at the level of the course, to be worked out on paper. Hints one at a time, then the answer or the full worked solution, with your progress kept in this browser.

Core practice Work it out on paper 10 problems Start →
More practice (optional)

Extra sets, as hard as the Challenge set. Each one opens on its own page.

More resources (optional)

Other explanations of this lesson, if you want a second take.

Go deeper (optional)

You can skip this and keep going. Read it if you want to know more.

Why ⌊x⌋≤x<⌊x⌋+1\lfloor x \rfloor \le x < \lfloor x \rfloor + 1

Why ⌊x⌋≤x<⌊x⌋+1\lfloor x \rfloor \le x < \lfloor x \rfloor + 1#

For x=3.7x=3.7, the floor is 33: it is at or below 3.73.7, and the next integer, 44, is above it. Here is why the same bounds hold for every real input.

Name the floor n=⌊x⌋n = \lfloor x \rfloor. Two facts come straight from the definition. First, nn is an integer with n≤xn \le x, because the floor was chosen from among the integers that are at most xx. Second, the next integer up, n+1n + 1, is bigger than nn, so it cannot also be one of the integers at most xx. If n+1n + 1 were one of those integers, then nn would not have been the greatest integer that is at most xx. So n+1>xn + 1 > x, which is the same as x<n+1x < n + 1. Putting the two facts together,

n≤x<n+1.n \le x < n + 1.
A sign-flip identity that turns a floor into a ceiling

Worked example Show that ⌈x⌉=−⌊−x⌋\lceil x \rceil = -\lfloor -x \rfloor and use it on ⌈4.2⌉\lceil 4.2 \rceil

Start with the ceiling bounds for 4.24.2. Negate every part and write the numbers in increasing order:

4<4.2≤5−5≤−4.2<−4.\begin{gathered} 4<4.2\le5 \\ -5\le-4.2<-4. \end{gathered}

This shows ⌊−4.2⌋=−5\lfloor-4.2\rfloor=-5. Negating the result gives the ceiling:

−⌊−4.2⌋=−(−5)=5=⌈4.2⌉.\begin{aligned} -\lfloor-4.2\rfloor&=-(-5)\\ &=5=\lceil4.2\rceil. \end{aligned}

Negating reflects the number line, swapping left and right. This explains the general rule too. Let m=⌈x⌉m=\lceil x\rceil, the least integer at or above xx. The ceiling bounds say

m−1<x≤m.m-1<x\le m.

Negate every part and reverse the inequalities. Written in increasing order, they become

−m≤−x<−m+1.-m\le -x<-m+1.

Thus −m-m is the greatest integer at or below −x-x, which means ⌊−x⌋=−m=−⌈x⌉\lfloor-x\rfloor=-m=-\lceil x\rceil. Negating both sides gives

⌈x⌉=−⌊−x⌋.\lceil x\rceil=-\lfloor-x\rfloor.

This agrees with rounding 4.24.2 up directly.

A bit of history (optional)

Rounding down had familiar notation long before today’s matching floor and ceiling brackets.

In 1808, Carl Friedrich Gauss used [x][x] for the greatest integer not exceeding xx. Plain square brackets continued to appear in mathematical writing for more than a century. With that notation, the sign-flip identity from this lesson would write the ceiling as −[−x]-[-x]: reverse direction, round down, then reverse back. (Gauss’s notation)

These operations also come up in computing. Programs often need to count full groups or round up for space: pages for a document, storage units for a file, or buses for a group. In 1962, Kenneth Iverson’s A Programming Language used the names floor and ceiling with the symbols ⌊x⌋\lfloor x\rfloor and ⌈x⌉\lceil x\rceil. His definitions are the same two inequalities used here. (Iverson’s 1962 paper)

The brackets are a small picture of their meanings. The floor’s feet point along the bottom; the ceiling’s marks run across the top. Seeing which way they point helps you choose the right integer.

Your progress

See all your progress →