math.wiki
Functions › Piecewise and absolute value functions › Step functions and the greatest integer function
Open on the map
Algebra 1 · F.IF.C.7B · F.IF.C.7

Step functions and the greatest integer function

How do you write and draw a rule that stays flat for a while and then jumps, such as a charge for every started half hour?

Where you are 4 in Piecewise and absolute value functions

Why this exists

Some quantities do not change smoothly. Your age in whole years stays the same for a full year and then jumps by 1 on your birthday. An e-scooter scheme that charges for every started half hour charges the same for a 31-minute ride as for a 59-minute one, and more for a 61-minute one. The graph of either stays flat, leaps up, and stays flat again.

No straight line does that. A piecewise function can, with one flat piece per stretch, but a rule that steps at every whole number would need endlessly many pieces. This lesson gives that whole staircase one name, the greatest integer function, and uses it to write any rule that charges by the started unit. The staircases in Graphing a function from a table and Reading values off a graph now get a formula.

Definition

For any real number x, the greatest integer function gives the greatest integer that is less than or equal to x. It is written \lfloor x \rfloor and also called the floor of x. In plain words, it rounds x down to the integer at or below it.

“Down” means to the left on the number line, not toward zero, which matters for negative numbers:

\lfloor 3.7 \rfloor = 3 \qquad \lfloor 5 \rfloor = 5 \qquad \lfloor -2.3 \rfloor = -3

The integers at or below -2.3 are -3, -4, -5, \ldots, and the greatest of them is -3. An integer is its own floor. Some books write [x] for \lfloor x \rfloor.

The ceiling of x, written \lceil x \rceil, is the mirror image: the least integer greater than or equal to x. It rounds up, to the right: \lceil 3.2 \rceil = 4, \lceil -2.3 \rceil = -2 and \lceil 5 \rceil = 5.

A step function is a function whose graph is made of flat pieces, each a constant over its own interval, so that the graph changes only by jumping. The floor and the ceiling are the two basic step functions. Written as a piecewise function, the floor is

\lfloor x \rfloor = \begin{cases} \quad\vdots & \\ -1, & -1 \le x < 0 \\ 0, & 0 \le x < 1 \\ 1, & 1 \le x < 2 \\ 2, & 2 \le x < 3 \\ \quad\vdots & \end{cases}

with one piece for every integer, going on without end in both directions.

Intuition

x y −3 −2 −1 1 2 3 4 −3 −2 −1 1 2 3 4
y = \lfloor x \rfloor
y = x
Figure 1The greatest integer function. Each step includes its left end and stops just short of its right end.

Let x walk to the right from 0. While 0 \le x < 1, the greatest integer at or below x is 0, so the graph runs flat at height 0. At x = 1 the answer becomes 1 at once, and stays 1 until x reaches 2.

So each step has a closed dot at its left end and an open dot at its right end. The point (1, 1) is on the graph because \lfloor 1 \rfloor = 1; the point (1, 0) is not, because the piece at height 0 covers only 0 \le x < 1. At every integer an open dot sits directly below a closed one, and no vertical line joins them: a vertical segment would give one input many outputs, so it is never drawn, just as in Graphing a piecewise function.

The dashed line y = x runs through every closed dot. Rounding down never moves a number up, and never moves it down by a whole 1, so the staircase sits on or below that line, by less than 1.

Results

Defining inequality. For an integer n,

\lfloor x \rfloor = n \quad\text{exactly when}\quad n \le x < n + 1

Domain and range. The domain of \lfloor x \rfloor is all real numbers. The range is the integers, \{\ldots, -2, -1, 0, 1, 2, \ldots\}.

How far it rounds. For every real x,

x - 1 < \lfloor x \rfloor \le x

Adding an integer. If n is an integer, then \lfloor x + n \rfloor = \lfloor x \rfloor + n.

The ceiling. \lceil x \rceil = n exactly when n - 1 < x \le n, and

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

A charge per started unit. If every started unit of size u costs c, then an amount t > 0 costs

C(t) = c\,\lceil t / u \rceil
Why it is true

The floor exists and there is only one. Take a real number x. Some integers lie at or below it, and among them there is a largest, because integers are spaced 1 apart and cannot creep up on x forever. Call it n. Then n \le x, and n + 1 is an integer not at or below x, so x < n + 1. Conversely, if n \le x < n + 1, then n is at or below x and the next integer up is not, so n is the greatest. That is the defining inequality. Subtracting 1 from both sides of x < n + 1 gives x - 1 < n, the rounding result.

Domain and range. Every real number has a floor, so the domain is everything. Every output is an integer by definition, and every integer n is an output, since \lfloor n \rfloor = n.

Adding an integer. If \lfloor x \rfloor = m, then m \le x < m + 1. Adding the integer n throughout gives m + n \le x + n < m + n + 1, and m + n is an integer, so \lfloor x + n \rfloor = m + n.

The ceiling. Let \lfloor -x \rfloor = n, so n \le -x < n + 1. Multiplying by -1 flips both inequalities: -n - 1 < x \le -n. That is the ceiling’s inequality with -n in place of n, so \lceil x \rceil = -n = -\lfloor -x \rfloor.

Started units. With k units, an amount t is covered when ku \ge t, that is, when k \ge t/u. A unit is started only if it is needed, so k is the least integer at or above t/u, which is \lceil t/u \rceil, and each costs c.

Worked examples

Example 1

Rounding down and up

Find \lfloor 4.6 \rfloor, \lfloor -4.6 \rfloor, \lfloor 7 \rfloor, \lfloor -\tfrac{1}{3} \rfloor, \lceil 4.6 \rceil and \lceil -4.6 \rceil.

Solution

4.6 lies between the integers 4 and 5, so 4 \le 4.6 < 5 and \lfloor 4.6 \rfloor = 4.

-4.6 lies between -5 and -4, with -5 on its left. So -5 \le -4.6 < -4 and \lfloor -4.6 \rfloor = -5. Rounding a negative number down moves it further from zero.

7 is an integer, and the greatest integer at or below 7 is 7 itself: \lfloor 7 \rfloor = 7.

-\tfrac{1}{3} lies between -1 and 0, so \lfloor -\tfrac{1}{3} \rfloor = -1.

The ceiling takes the integer on the right instead: \lceil 4.6 \rceil = 5 and \lceil -4.6 \rceil = -4.

Check. Each floor is at most its number and less than 1 below it: 4.6 - 4 = 0.6 and -4.6 - (-5) = 0.4.

Example 2

Working back from an output

Find every x with (a) \lfloor x \rfloor = -2, (b) \lfloor 2x \rfloor = 5, (c) \lfloor x \rfloor = 1.5.

Solution

(a) The defining inequality with n = -2 gives -2 \le x < -1. A whole interval of inputs gives the one output, which is what a flat step is.

(b) Apply the defining inequality to the input 2x: 5 \le 2x < 6. Dividing by the positive number 2 keeps both inequalities, so 2.5 \le x < 3. Check the ends: \lfloor 2(2.5) \rfloor = \lfloor 5 \rfloor = 5, while at x = 3 the value is \lfloor 6 \rfloor = 6, so 3 is rightly left out.

(c) No x at all. Every output of the floor is an integer, and 1.5 is not in the range.

Example 3

Age in whole years

Age in whole years is the time since birth rounded down: A(t) = \lfloor t \rfloor, where t is the exact time since birth in years. Kaspian is 14 and Nerys is 11. (a) For which t is Kaspian’s age 14? (b) How far apart can their exact ages be?

Solution

(a) \lfloor t \rfloor = 14 exactly when 14 \le t < 15. The left end is included because Kaspian turns 14 at the moment t = 14; the right end is left out because at t = 15 he is 15. On the graph of A this is one step, with a closed dot at (14, 14) and an open dot at (15, 14).

(b) Kaspian’s exact age k satisfies 14 \le k < 15, and Nerys’s exact age m satisfies 11 \le m < 12. The difference k - m is largest with k large and m small, but stays below 15 - 11 = 4 because k never reaches 15. It is smallest with k small and m large, but stays above 14 - 12 = 2 because m never reaches 12. So

2 < k - m < 4

Their whole-year ages differ by 3, yet the true gap is anything strictly between 2 and 4.

Example 4

An e-scooter charge

An e-scooter scheme charges 1.50 dollars for every started 30 minutes, and a ride may last up to 2 hours. Write the cost C(t) of a ride of t minutes as a piecewise function and with the ceiling, graph it, and find what Meinrad pays for rides of 45, 60 and 61 minutes.

Solution

A ride of up to 30 minutes starts one half hour; a ride longer than 30 minutes, up to 60, starts two; and so on. The ends of each stretch decide the dots: a ride of exactly 30 minutes has started only one half hour, so t = 30 belongs to the first piece.

C(t) = \begin{cases} 1.50, & 0 < t \le 30 \\ 3.00, & 30 < t \le 60 \\ 4.50, & 60 < t \le 90 \\ 6.00, & 90 < t \le 120 \end{cases}

The number of half hours started is t/30 rounded up, so by the started-unit result

C(t) = 1.50\,\lceil t/30 \rceil, \qquad 0 < t \le 120
0 30 60 90 120 1.50 3.00 4.50 6.00 ride length (minutes) cost (dollars)
Figure 2A charge per started half hour. A ride of exactly 30 minutes still costs the lower price.

Each step now has its open dot on the left and its closed dot on the right, the reverse of the floor’s, because this is a ceiling.

For 45 minutes, \lceil 45/30 \rceil = \lceil 1.5 \rceil = 2, so C(45) = 3.00 dollars. For 60 minutes, \lceil 2 \rceil = 2, so C(60) = 3.00 dollars as well. For 61 minutes, 61/30 is a little more than 2, so \lceil 61/30 \rceil = 3 and C(61) = 4.50 dollars.

The domain is 0 < t \le 120 and the range is \{1.50, 3.00, 4.50, 6.00\}.

Example 5

Reading a step graph

Figure 3 shows the whole graph of a function g. Write g as a piecewise function, give its domain and range, and find g(2), g(1.99) and g(4). Then show that g(x) = 2\lfloor x/2 \rfloor + 3 on its domain.

x y −3 −2 −1 1 2 3 4 5 −1 1 2 3 4 5 6
y = g(x)
Figure 3The whole graph of g, for Example 5.
Solution

Read each flat piece together with its dots. The lowest runs at height 1 from a closed dot at x = -2 to an open dot at x = 0, so it covers -2 \le x < 0. The other two read the same way:

g(x) = \begin{cases} 1, & -2 \le x < 0 \\ 3, & 0 \le x < 2 \\ 5, & 2 \le x < 4 \end{cases}

The domain is -2 \le x < 4, and the range is \{1, 3, 5\}: the three heights and nothing between them.

x = 2 is the closed left end of the top step, so g(2) = 5. 1.99 is still in 0 \le x < 2, so g(1.99) = 3. g(4) is undefined: the only dot at x = 4 is open, so 4 is not in the domain.

The steps are 2 wide and rise by 2, like the floor stretched both ways. On 0 \le x < 2, 0 \le x/2 < 1, so \lfloor x/2 \rfloor = 0 and 2(0) + 3 = 3. On 2 \le x < 4, \lfloor x/2 \rfloor = 1, giving 5. On -2 \le x < 0, \lfloor x/2 \rfloor = -1, giving 1. All three pieces match.

Example 6

Counting multiples

How many multiples of 7 are there from 1 to 100? From 200 to 500?

Solution

The positive multiples of 7 are 7k for k = 1, 2, 3, \ldots, and 7k \le 100 exactly when k \le 100/7 \approx 14.29. So k runs from 1 up to the greatest integer at or below 100/7:

\lfloor 100/7 \rfloor = 14

There are 14, the last being 7 \times 14 = 98.

For 200 to 500, count the multiples up to 500 and take away those up to 199:

\lfloor 500/7 \rfloor - \lfloor 199/7 \rfloor = 71 - 28 = 43

Check. The first is 7 \times 29 = 203 and the last is 7 \times 71 = 497, and 71 - 29 + 1 = 43.

Boundaries

Down means left, not toward zero. Chopping off the decimals gives the floor of x \ge 0 and of any integer. For -2.3, chopping gives -2, but \lfloor -2.3 \rfloor = -3.

The floor is not the nearest integer. \lfloor 2.9 \rfloor = 2, though 3 is nearer. Rounding to the nearest integer is a different function; Exercise 16 builds it from the floor.

Floor and ceiling differ by 1 only between integers. For x not an integer, \lceil x \rceil = \lfloor x \rfloor + 1; at an integer the two are equal.

The floor does not split over sums or products. \lfloor 0.5 + 0.5 \rfloor = 1, but \lfloor 0.5 \rfloor + \lfloor 0.5 \rfloor = 0; and \lfloor 2(0.5) \rfloor = 1, while 2\lfloor 0.5 \rfloor = 0. Adding an integer is the one safe move.

A context sets the domain. 1.50\lceil t/30 \rceil produces a number for t = 0 or t = 500, but the scheme has no ride of 0 minutes and none over 120. The formula holds only on the domain the situation allows.

A step function jumps. At each integer the floor leaps by 1, so its graph cannot be drawn without lifting the pencil. That break is a Discontinuities and how to remove them.

Where this goes next

The floor never falls: it is constant on each step and rises only at the jumps, the kind of behavior Increasing, decreasing, constant, positive and negative intervals puts names to. Charges that change at thresholds of unequal size, like tax bands, are Piecewise functions in context, and reading a rule back off a graph with open and closed dots is Writing a piecewise rule from a graph. To evaluate a step rule written with a brace, see Evaluating a piecewise function. In calculus, the jump at each integer is the standard example where the left and right limits disagree: as x approaches 3 from the left, \lfloor x \rfloor stays at 2, and from the right it is already 3.

Exercises

Evaluating

  1. Find \lfloor 8.01 \rfloor, \lfloor -8.01 \rfloor, \lfloor -6 \rfloor and \lfloor -\tfrac{1}{4} \rfloor.
  2. Find \lceil 8.01 \rceil, \lceil -8.01 \rceil and \lceil -6 \rceil.
  3. Find \lfloor 3.5 \rfloor + \lfloor -3.5 \rfloor.

Working back from an output

  1. Find every x with \lfloor x \rfloor = 6.
  2. Find every x with \lfloor x \rfloor = -1.
  3. Find every x with \lceil x \rceil = 2.
  4. Find every x with \lfloor 3x \rfloor = 4.

Reading a step graph

Figure 4 shows the whole graph of a function h.

x y −1 1 2 3 4 −1 1 2 3 4 5 6 7
y = h(x)
Figure 4The whole graph of h, for Exercises 8 to 10.
  1. Find h(1), h(1.5) and h(3).
  2. Give the domain and range of h.
  3. Write h as a piecewise function, and show that it agrees with 8 - 2\lceil x \rceil on its domain.

Step functions in context

  1. A library charges a fine of 0.40 dollars for every started week a book is overdue. Find the fine for a book 3, 7, 8 and 20 days late, and write the fine F(d) for d days late using the ceiling.
  2. Lavender paid a fine of 2.00 dollars at the library in Exercise 11. How many whole days late could her book have been?
  3. Ignatia has 4.00 dollars for the e-scooter in Example 4. What is the longest ride she can afford, and how much will she have left?
  4. Jules-Henri is 9 years old in whole years. What exact ages t are possible, and how old will he be, in whole years, exactly 5 years from now?
  5. How many multiples of 6 are there from 1 to 250? From 100 to 250?

Reasoning

  1. Show that \lfloor x + \tfrac{1}{2} \rfloor rounds x to the nearest integer, with halves going up. Use it to round 2.3, 2.7 and -2.5.
  2. Show that if x is not an integer, then \lfloor -x \rfloor = -\lfloor x \rfloor - 1. What happens when x is an integer?
  3. Meinrad writes the e-scooter cost of Example 4 as 1.50\left(\lfloor t/30 \rfloor + 1\right). For which ride lengths does this agree with 1.50\lceil t/30 \rceil, and what does it charge for a ride of exactly 60 minutes?
Answers
  1. 8, -9, -6 and -1. -8.01 lies between -9 and -8, so it rounds down to -9; -6 is an integer; -\tfrac{1}{4} lies between -1 and 0.
  2. 9, -8 and -6. The ceiling takes the integer at or to the right, so -8.01 goes up to -8.
  3. -1. \lfloor 3.5 \rfloor = 3 and \lfloor -3.5 \rfloor = -4, so the sum is 3 + (-4) = -1, not 0.
  4. 6 \le x < 7, the defining inequality with n = 6.
  5. -1 \le x < 0, the defining inequality with n = -1.
  6. 1 < x \le 2, the ceiling’s inequality n - 1 < x \le n with n = 2.
  7. \tfrac{4}{3} \le x < \tfrac{5}{3}. The defining inequality gives 4 \le 3x < 5; divide by the positive number 3.
  8. h(1) = 6, h(1.5) = 4, h(3) = 2. At x = 1 the closed dot is on the top step, and x = 3 is the closed right end of the lowest step.
  9. Domain 0 < x \le 3; range \{2, 4, 6\}. The dot at x = 0 is open and the one at x = 3 is closed.
  10. h(x) = 6 for 0 < x \le 1, 4 for 1 < x \le 2 and 2 for 2 < x \le 3. On these three pieces \lceil x \rceil is 1, 2 and 3, and 8 - 2(1) = 6, 8 - 2(2) = 4, 8 - 2(3) = 2.
  11. 0.40, 0.40, 0.80 and 1.20 dollars, and F(d) = 0.40\lceil d/7 \rceil. 3 and 7 days start one week, 8 days start two, and 20/7 \approx 2.86 rounds up to 3.
  12. From 29 to 35 days. 2.00 \div 0.40 = 5 started weeks, so \lceil d/7 \rceil = 5, which means 4 < d/7 \le 5, or 28 < d \le 35.
  13. A ride of up to 60 minutes, leaving 1.00 dollar. C(60) = 3.00, but any ride over 60 minutes costs 4.50, more than she has.
  14. 9 \le t < 10, and he will be 14: \lfloor t + 5 \rfloor = \lfloor t \rfloor + 5 = 14, since 5 is an integer.
  15. 41 and 25. \lfloor 250/6 \rfloor = 41, the last being 246. From 100 to 250: \lfloor 250/6 \rfloor - \lfloor 99/6 \rfloor = 41 - 16 = 25.
  16. 2, 3 and -2. If n is the nearest integer to x, with a half going up, then n - \tfrac{1}{2} \le x < n + \tfrac{1}{2}. Adding \tfrac{1}{2} throughout gives n \le x + \tfrac{1}{2} < n + 1, so \lfloor x + \tfrac{1}{2} \rfloor = n. The three values are \lfloor 2.8 \rfloor = 2, \lfloor 3.2 \rfloor = 3 and \lfloor -2 \rfloor = -2.
  17. Let \lfloor x \rfloor = n. As x is not an integer, n < x < n + 1, both strict. Multiplying by -1 gives -n - 1 < -x < -n, so \lfloor -x \rfloor = -n - 1 = -\lfloor x \rfloor - 1. When x is an integer, \lfloor -x \rfloor = -x = -\lfloor x \rfloor. For instance, \lfloor -3.5 \rfloor = -4 = -3 - 1.
  18. For every t that is not a multiple of 30; at t = 30, 60, 90 and 120 it charges 1.50 dollars too much. Between multiples t/30 is not an integer, so \lceil t/30 \rceil = \lfloor t/30 \rfloor + 1. At t = 60 the formula gives 1.50(2 + 1) = 4.50 dollars, but a ride of exactly an hour starts only two half hours and costs 3.00.
kg1128 · updated 2026-10-10 · CC-BY-SA-4.0