practicecalculus
Special and piecewise functions

Floor and Ceiling Functions: Graphs, Limits, Derivative, Integral

The floor function ⌊x⌋ and ceiling function ⌈x⌉: definitions, step graphs, one-sided limits, continuity, derivative and how to integrate them.

Special and piecewise functions Updated 4 min read

At a glance

\lfloor x \rfloor = \max\{n \in \mathbb{Z} : n \le x\}, \quad \lceil x \rceil = \min\{n \in \mathbb{Z} : n \ge x\}
Domain
(-\infty, \infty)
Range
The integers \mathbb{Z}
Derivative
\frac{d}{dx}\lfloor x \rfloor = 0 \ \ (x \notin \mathbb{Z})
Integral
\int_0^x \lfloor t \rfloor\,dt = \lfloor x \rfloor x - \frac{\lfloor x \rfloor(\lfloor x \rfloor + 1)}{2}
Discontinuities
A jump of size 1 at every integer
Relation
\lceil x \rceil = -\lfloor -x \rfloor
On this page
  1. Definitions
  2. Graph of the floor function
  3. Graph of the ceiling function
  4. Key properties
  5. Limits and continuity
  6. Derivative of the floor function
  7. Integral of the floor function
  8. Common mistakes
  9. Where you will see them

The floor function \lfloor x\rfloor rounds a number down to the nearest integer, and the ceiling function \lceil x\rceil rounds it up. Their graphs look like staircases, which makes them the classic examples of piecewise functions with jump discontinuities. The floor function is also called the greatest integer function and is sometimes written [x] or \operatorname{int}(x).

Definitions

\lfloor x\rfloor = \text{the largest integer } n \text{ with } n \le x, \qquad \lceil x\rceil = \text{the smallest integer } n \text{ with } n \ge x
x 2.7 2 0.4 -0.4 -2.7
\lfloor x\rfloor 2 2 0 -1 -3
\lceil x\rceil 3 2 1 0 -2

Watch the negative numbers: rounding -2.7 down moves it to -3, not -2.

Graph of the floor function

Graph of the floor function y = ⌊x⌋ from x = −1 to x = 3
Each step includes its left endpoint (closed dot) and excludes its right endpoint (open dot), because \lfloor n\rfloor = n at every integer n.

Graph of the ceiling function

Graph of the ceiling function y = ⌈x⌉ from x = −1 to x = 3
The ceiling steps are closed on the right and open on the left, the mirror image of the floor function.

Key properties

  • Range. Both functions output only integers.
  • Bounds. x - 1 < \lfloor x\rfloor \le x \le \lceil x\rceil < x + 1.
  • Integers are fixed. \lfloor n\rfloor = \lceil n\rceil = n for any integer n.
  • Shifting by an integer. \lfloor x + n\rfloor = \lfloor x\rfloor + n for any integer n.
  • Floor and ceiling are linked. \lceil x\rceil = -\lfloor -x\rfloor, and for a non-integer x, \lceil x\rceil = \lfloor x\rfloor + 1.

Limits and continuity

Between integers the floor function is constant, so it is continuous there. At an integer n the one-sided limits disagree:

\lim_{x\to n^-}\lfloor x\rfloor = n - 1, \qquad \lim_{x\to n^+}\lfloor x\rfloor = n

So \lim_{x\to n}\lfloor x\rfloor does not exist, and there is a jump of size 1. Since the right-hand limit equals \lfloor n\rfloor, the floor function is right-continuous. The ceiling function is the reverse: \lim_{x\to n^-}\lceil x\rceil = n and \lim_{x\to n^+}\lceil x\rceil = n + 1, so it is left-continuous. For the formal definitions, see the guide to continuity.

Example: a limit at infinity. Find \lim_{x\to\infty}\frac{\lfloor x\rfloor}{x}. For x > 0, dividing x - 1 < \lfloor x\rfloor \le x by x gives 1 - \frac{1}{x} < \frac{\lfloor x\rfloor}{x} \le 1. Both bounds approach 1, so by the squeeze theorem the limit is 1.

Derivative of the floor function

\frac{d}{dx}\lfloor x\rfloor = 0 \quad \text{for } x \notin \mathbb{Z}

On each open interval (n, n+1) the function is the constant n, whose derivative is 0. At an integer the function is not continuous, so it is not differentiable. The same holds for the ceiling function.

Integral of the floor function

Each unit interval [k, k+1] contributes a rectangle of height k and width 1, so you add up rectangle areas, much like a Riemann sum that happens to be exact. For x \ge 0:

\int_0^x\lfloor t\rfloor\,dt = (0 + 1 + \cdots + (n - 1)) + n(x - n) = nx - \frac{n(n+1)}{2}, \qquad n = \lfloor x\rfloor

The same formula also holds for negative x.

Example. \int_0^{3.5}\lfloor t\rfloor\,dt = 0 + 1 + 2 + 3(0.5) = 4.5. The formula agrees: 3(3.5) - \frac{3\cdot 4}{2} = 10.5 - 6 = 4.5.

Example with ceiling. \int_0^3\lceil t\rceil\,dt = 1 + 2 + 3 = 6, since \lceil t\rceil equals 1 on (0, 1], 2 on (1, 2] and 3 on (2, 3]. Single points do not affect an integral.

Common mistakes

  1. Rounding negatives toward zero. \lfloor -1.2\rfloor = -2, not -1.
  2. Claiming the limit at an integer exists. The left and right limits differ by 1.
  3. Putting the closed dot on the wrong end. Floor steps are closed on the left; ceiling steps are closed on the right.
  4. Differentiating at a jump. The derivative is 0 only between integers. At the integers it does not exist.

Where you will see them

Step functions model anything charged in whole units: postage by the ounce, parking by the hour, or tax brackets. In calculus they are the go-to examples for one-sided limits and for functions that are integrable but not continuous. See the general strategy on piecewise functions, and compare with the corner of the absolute value function.

Practice it now

One-sided and infinite limits

Solve real problems on this topic with instant feedback, hints and a step-by-step walkthrough for every answer. Free, no sign-up needed to start.

Practice this lesson

Frequently asked questions

What is the floor function?

The floor function \lfloor x\rfloor, also called the greatest integer function, gives the largest integer less than or equal to x. For example \lfloor 2.7\rfloor = 2 and \lfloor -2.7\rfloor = -3.

What is the difference between floor and ceiling?

Floor rounds down and ceiling rounds up. They agree on integers, and for a non-integer x the ceiling is exactly one more than the floor.

Is the floor function continuous?

It is continuous at every non-integer and has a jump discontinuity at every integer. It is right-continuous everywhere: \lim_{x\to n^+}\lfloor x\rfloor = n = \lfloor n\rfloor.

What is the derivative of the floor function?

Between integers the floor function is constant, so its derivative is 0. At each integer it jumps, so it is not differentiable there.

How do you integrate the floor function?

Split the interval at the integers. On each piece the function is constant, so each piece contributes a rectangle, for example \int_0^3\lfloor x\rfloor\,dx = 0 + 1 + 2 = 3.

Written by the PracticeCalculus team

We build interactive calculus lessons and write every page to be clear and correct. Spotted something off? Tell us and we will fix it.