Mathwords logoMathwords

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 xx, the floor function x\lfloor x \rfloor is defined as the greatest integer nn such that nxn \leq x. The ceiling function x\lceil x \rceil is defined as the least integer nn such that nxn \geq x. Both functions map RZ\mathbb{R} \to \mathbb{Z}.

Key Formula

x=max{nZnx}x=min{nZnx}\lfloor x \rfloor = \max\{n \in \mathbb{Z} \mid n \leq x\} \qquad \lceil x \rceil = \min\{n \in \mathbb{Z} \mid n \geq x\}
Where:
  • xx = Any real number
  • nn = An integer
  • x\lfloor x \rfloor = The floor of x (greatest integer ≤ x)
  • x\lceil x \rceil = The ceiling of x (least integer ≥ x)

How It Works

The floor function, written x\lfloor x \rfloor, chops off the decimal part of a positive number, always rounding toward negative infinity. The ceiling function, written x\lceil x \rceil, rounds up toward positive infinity. When xx is already an integer, both functions return xx 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.
3<2.3<2-3 < -2.3 < -2
Step 2: The floor is the greatest integer less than or equal to −2.3. Since −3 ≤ −2.3, the floor is −3.
2.3=3\lfloor -2.3 \rfloor = -3
Step 3: The ceiling is the least integer greater than or equal to −2.3. Since −2 ≥ −2.3, the ceiling is −2.
2.3=2\lceil -2.3 \rceil = -2
Answer: 2.3=3\lfloor -2.3 \rfloor = -3 and 2.3=2\lceil -2.3 \rceil = -2

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.
25320=12.65\frac{253}{20} = 12.65
Step 2: The number of completely full rows uses the floor function.
12.65=12 full rows\lfloor 12.65 \rfloor = 12 \text{ full rows}
Step 3: The total number of rows needed (including a partial row) uses the ceiling function.
12.65=13 rows needed\lceil 12.65 \rceil = 13 \text{ rows needed}
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 nn 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 2.3=2\lfloor -2.3 \rfloor = -2.
Correction: Floor always rounds toward negative infinity. Since 3<2.3<2-3 < -2.3 < -2, the greatest integer that is still ≤ −2.3 is −3, so 2.3=3\lfloor -2.3 \rfloor = -3.
Mistake: Confusing floor with standard rounding. Students write 4.8=5\lfloor 4.8 \rfloor = 5 because 4.8 is "closer to 5."
Correction: Floor never rounds up regardless of the decimal part. 4.8=4\lfloor 4.8 \rfloor = 4 because floor returns the greatest integer that does not exceed the input.

Related Terms