This site is a work in progress. New lessons are added regularly. Contact us

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 xxx - \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 whole numbers 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 whole numbers 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.

Every one of those computations used the same test: find the integer that fits snugly against xx from below (for the floor) or from above (for the ceiling). That test is worth writing as an inequality, because it is the engine behind everything else.

Why xx<x+1\lfloor x \rfloor \le x < \lfloor x \rfloor + 1#

Name the floor n=xn = \lfloor x \rfloor. Two facts come straight from the definition. First, nn is an integer with nxn \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,

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

This traps xx in a half-open interval of length 11 whose left end is the floor. The floor is the only integer that does this. If some other integer mm also satisfied mx<m+1m \le x < m + 1, then mm and nn would both lie within the same length-11 interval containing xx, forcing mn<1\lvert m - n \rvert < 1. But two different integers differ by at least 11, so m=nm = n. That uniqueness is what makes the inequality a computation tool: to find a floor, find any integer kk with kx<k+1k \le x < k + 1. Because no other integer can satisfy that inequality, you can be sure that kk is the one and only x\lfloor x \rfloor.

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

x1<xx.\lceil x \rceil - 1 < x \le \lceil x \rceil.

These two inequalities also settle what happens at the boundary between the two functions. When xx is an integer, it is both the greatest integer at or below and the least integer at or above itself, so

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

When xx is not an integer, the left inequality nxn \le x becomes strict, n<x<n+1n < x < n + 1, so xx lands strictly between the consecutive integers nn and n+1n + 1. The least integer at or above xx is then n+1n + 1, which gives a clean relationship between the two:

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, which is always true: the floor and ceiling only ever return whole numbers.

Rounding down is not the same as chopping off the decimal

Everything above is easy to misread once negative numbers appear, and this is the single most common mistake with these functions. “Round down” means move to the left on the number line, toward smaller values. It does not mean “delete the part after the decimal point.”

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 tempting 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

To graph y=xy = \lfloor x \rfloor, group the inputs by the value they produce. The defining inequality says x=n\lfloor x \rfloor = n exactly when nx<n+1n \le x < n + 1. So on the whole interval from nn up to (but not including) n+1n + 1, the floor holds steady at the height nn. That makes the graph a flat horizontal segment at height nn running across that interval. The graph then jumps up by one at x=n+1x = n + 1 to start the next segment. The result is a staircase.

Look carefully at the ends of one step. On the interval for height nn, the left end x=nx = n is included, because n=n\lfloor n \rfloor = n, so that end is a filled (closed) dot. The right end x=n+1x = n + 1 is not included, because at x=n+1x = n + 1 the floor has already jumped to n+1n + 1, so that end is a hollow (open) dot. Every step of the floor is therefore closed on the left and open on the right.

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.

The ceiling graph is the same staircase read the other way. Since x=n\lceil x \rceil = n exactly when n1<xnn - 1 < x \le n, each ceiling step holds the height nn across the interval that ends at x=nx = n. For a ceiling step the included end is now on the right (because n=n\lceil n \rceil = n), and the excluded end is on the left. So every ceiling step is open on the left and closed on the right, the mirror image of the floor.

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, the mirror image of the floor staircase.xy-3-2-112304321-1-2y = ⌈x⌉
The graph of y equals the ceiling of x, the mirror of 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 a whole number, 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 are what carry that information.

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:

3x<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<x2.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}=xx.\{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 nx<n+1n \le x < n + 1 with n=xn = \lfloor x \rfloor and subtract nn from every part:

0xn<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.73=0.7\{3.7\} = 3.7 - 3 = 0.7, the digits after the decimal point. But watch what happens with a negative input, where the floor surprise strikes again. 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 of 2.3-2.3 is 0.70.7, not 0.30.3. It has to be, since {x}\{x\} can never be negative, and it measures how far xx has climbed above the step below it. On the integers the leftover is nothing at all, {5}=55=0\{5\} = 5 - 5 = 0, which is the only time the fractional part equals 00.

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

Use {x}=xx\{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.85.8=5.85=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.21.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) as promised. And notice that 1.2-1.2 and 5.85.8 have the same fractional part 0.80.8, which makes sense. The two numbers are exactly 77 apart, a whole number of steps, so they sit the same distance above their respective floors.

There is a tidy identity that ties the floor and ceiling together through a sign flip. Reflecting the number line by sending xx to x-x swaps left with right. That reflection also swaps “at or below” with “at or above,” so it should turn a floor into a ceiling.

Worked example 5 Show that x=x\lceil x \rceil = -\lfloor -x \rfloor and use it on 4.2\lceil 4.2 \rceil

Let m=xm = \lceil x \rceil, the least integer with mxm \ge x. Negating both sides of mxm \ge x reverses the inequality to mx-m \le -x. Because mm was the least integer at or above xx, the reflected value m-m is the greatest integer at or below x-x. That is precisely the floor of x-x:

x=x.\lfloor -x \rfloor = -\lceil x \rceil.

Negating both sides gives the identity x=x\lceil x \rceil = -\lfloor -x \rfloor. To use it on 4.2\lceil 4.2 \rceil, compute the floor of the negated input first, then flip the sign:

4.2=4.2=(5)=5.\lceil 4.2 \rceil = -\lfloor -4.2 \rfloor = -(-5) = 5.

That agrees with rounding 4.24.2 up directly, and it shows you never need a separate rule for the ceiling: a floor and two sign flips always deliver it.

Check your understanding

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

Answer choices

Where floor and ceiling show up

The reason these functions matter is counting. Whenever a real-number answer has to be turned into a whole number of things, one of the two brackets is exactly the right tool. The choice between the two brackets is never arbitrary.

Use a ceiling when every leftover still needs a full container. If 5353 students travel in vans that seat 1212, then 53÷12=4.4153 \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,

5312×53/12=5348=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.

Both answers live in one picture, and it is worth building. Lay nn objects into rows that hold cc each. The number of rows that come out complete is n/c\lfloor n/c \rfloor, and the number of rows the objects occupy at all, counting a partly filled last row, is n/c\lceil n/c \rceil. The figure below draws those rows and hollows out any object that could not complete one.

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 complete rows while 10/4=3\lceil 10/4 \rceil = 3 rows are needed to hold everything. The hollow dots are the remainder, 104×210 - 4 \times 2, and the third row is the one they force. Count them if you like, but it is their presence and never their number that pushes the ceiling above the floor. Two hollow dots here open a gap of one, and so would four. Widen the rows to 55 and the same 1010 dots settle into two full rows with nothing hollow, so floor and ceiling agree at 22. The readout confirms why by reporting that the row width is now a factor of the count. Narrow the rows to 33 instead and one dot is left hollow again, splitting the answers to 33 and 44. Walk the row width up and down a few times and the rule becomes hard to miss. The two functions differ by exactly one whenever anything is left over, and are equal whenever the division comes out even.

Dot array

10 dots in rows of 4 make 2 full rows with 2 dots left over. So 4 is not a factor of 10. 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 4 is not a factor of 10.

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 whether a dot is left hollow at all is exactly what separates the two.

Rounding to the nearest integer is a floor in disguise: adding 12\tfrac12 first and then flooring rounds a number to its closest whole value. That works because x+12\lfloor x + \tfrac12 \rfloor steps up to the next integer exactly when xx has passed the halfway mark.

Worked example 6 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 15040×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.

Common mistakes

Practice

Multiple Choice Questions (MCQ)

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

Free Response Questions (FRQ)

Longer questions in parts, to be worked out on paper. Progressive hints, the answer on its own so you can check yourself and try again, then the full worked solution, plus a rubric to mark your own work against.

Free response Work it out on paper 5 questions 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.

A bit of history (Optional)

Rounding down had a symbol of its own long before rounding up did.

In 1808 the German mathematician Carl Friedrich Gauss wrote [x][x] for the greatest integer that does not exceed xx. A plain square bracket was enough for what he was doing, and it stuck for over a century. But it only pointed one way. Anyone who needed to round up wrote [x]-[-x] instead. That is the sign flip you proved in this lesson, pressed into service to cover a missing symbol.

The repair came from computing rather than from mathematics. Programs round up constantly. How many disks hold this file? How many lines fit on this page? How many buses carry this many children? A language that answers such questions awkwardly will eventually answer one of them wrong.

So a new notation was invented for the job. In 1962 Kenneth Iverson, describing a programming language of his own design, introduced x\lfloor x \rfloor and x\lceil x \rceil. He named them the floor and the ceiling. The brackets are a small picture of what they mean. The floor’s have feet planted on the ground, and the ceiling’s hang down from above.

Rounding up had finally stopped borrowing. That is why the two functions arrive together in this lesson, as mirror images, rather than one of them being a trick played on the other.