Floor and Ceiling Functions — Definition, Formula & Examples
The floor function rounds a number down to the nearest integer, while the ceiling function rounds a number up to the nearest integer. For example, the floor of 3.7 is 3, and the ceiling of 3.7 is 4.
For any real number , the floor function is defined as the greatest integer such that . The ceiling function is defined as the least integer such that . Both functions map .
Key Formula
Where:
- = Any real number
- = An integer
- = The floor of x (greatest integer ≤ x)
- = The ceiling of x (least integer ≥ x)
How It Works
The floor function, written , chops off the decimal part of a positive number, always rounding toward negative infinity. The ceiling function, written , rounds up toward positive infinity. When is already an integer, both functions return itself. These functions appear whenever you need whole-number answers from real-number inputs — for instance, figuring out how many buses are needed for a field trip (ceiling) or how many complete sets you can make from a supply (floor).
Worked Example
Problem: Evaluate the floor and ceiling of −2.3.
Step 1: Identify the two consecutive integers that −2.3 lies between.
Step 2: The floor is the greatest integer less than or equal to −2.3. Since −3 ≤ −2.3, the floor is −3.
Step 3: The ceiling is the least integer greater than or equal to −2.3. Since −2 ≥ −2.3, the ceiling is −2.
Answer: and
Another Example
Problem: A theater has 253 seats arranged in rows of 20. How many full rows are there, and how many rows are needed to seat everyone?
Step 1: Divide the total seats by the row size.
Step 2: The number of completely full rows uses the floor function.
Step 3: The total number of rows needed (including a partial row) uses the ceiling function.
Answer: There are 12 full rows, but 13 rows are needed to seat all 253 people.
Visualization
Why It Matters
Floor and ceiling functions appear in discrete mathematics and computer science courses, where algorithms often require integer results from real-number calculations. Programmers use them constantly — for example, computing array indices, pagination (how many pages to display items), and hash functions. They also show up in number theory proofs involving integer parts of quotients.
Common Mistakes
Mistake: Treating floor as "round toward zero" for negative numbers — for example, writing .
Correction: Floor always rounds toward negative infinity. Since , the greatest integer that is still ≤ −2.3 is −3, so .
Mistake: Confusing floor with standard rounding. Students write because 4.8 is "closer to 5."
Correction: Floor never rounds up regardless of the decimal part. because floor returns the greatest integer that does not exceed the input.
