Mathematics.

functions on the integers

Floor and Ceiling Functions

Discrete Mathematics18 minDifficulty2 out of 10

You should know: functions

Overview

The floor function ⌊x⌋ rounds a real number x down to the nearest integer, and the ceiling function ⌈x⌉ rounds it up to the nearest integer. Both take a continuous input and return a discrete integer output, which makes them the natural bridge between real-number arithmetic and integer-indexed structures like arrays, pages, and clock arithmetic. Unlike ordinary rounding (which rounds to the nearest integer in either direction), floor always moves toward negative infinity and ceiling always moves toward positive infinity, so for a non-integer x the two differ by exactly 1: ⌈x⌉ = ⌊x⌋ + 1. These functions appear constantly in discrete mathematics — counting multiples, computing array indices, expressing the number of bits needed to represent a number, and defining the mod operation itself.

Intuition

Picture the real number line marked at every integer. Floor asks 'which integer marker is at or just below me?' and always steps down (or stays put) to find it; ceiling asks the mirror question and steps up. If x is already an integer, both functions leave it alone — there's nowhere to round. If x sits strictly between two integers, floor takes the lower fence and ceiling takes the upper fence, and since consecutive integers are exactly 1 apart, the two answers are exactly 1 apart too. A common use: 'how many boxes of 12 do I need to pack n items?' is ⌈n/12⌉, because any leftover items still need one more (partially filled) box — ceiling, not floor, models 'round up to cover everything.'

Formal Definition

Definition

For a real number x, the floor and ceiling are defined as the greatest integer not exceeding x, and the least integer not less than x, respectively:

x=max{nZnx}\lfloor x \rfloor = \max\{\, n \in \mathbb{Z} \mid n \le x \,\}
Floor function
x=min{nZnx}\lceil x \rceil = \min\{\, n \in \mathbb{Z} \mid n \ge x \,\}
Ceiling function
x1<xxx<x+1x - 1 < \lfloor x \rfloor \le x \le \lceil x \rceil < x + 1
Bounding inequalities
x=x+1if xZ,x=xif xZ\lceil x \rceil = \lfloor x \rfloor + 1 \quad \text{if } x \notin \mathbb{Z}, \qquad \lceil x \rceil = \lfloor x \rfloor \quad \text{if } x \in \mathbb{Z}
Relationship between floor and ceiling
x+x={0xZ1xZ\lfloor x \rfloor + \lfloor -x \rfloor = \begin{cases} 0 & x \in \mathbb{Z} \\ -1 & x \notin \mathbb{Z} \end{cases}
Floor of a negated argument

Worked Examples

  1. 3.7 lies between the integers 3 and 4. Floor rounds down to 3.

    3.7=3\lfloor 3.7 \rfloor = 3
  2. Ceiling rounds up to 4.

    3.7=4\lceil 3.7 \rceil = 4

Answer: ⌊3.7⌋ = 3 and ⌈3.7⌉ = 4.

Practice Problems

Difficulty 1/10

Evaluate ⌊7.9⌋ and ⌈7.1⌉.

Difficulty 2/10

Evaluate ⌊-5⌋ and ⌈-5⌉.

Difficulty 4/10

A parking garage charges for full hours only, always rounding a partial hour up to the next full hour. A car parks for 3.25 hours. Using the ceiling function, how many hours is the car billed for?

Quiz

For a non-integer x, ⌈x⌉ equals:
⌊-1.5⌋ equals:
The number of boxes of size k needed to pack n items (n, k positive integers) is best modeled by:

Summary

  • ⌊x⌋ is the greatest integer ≤ x (round toward −∞); ⌈x⌉ is the least integer ≥ x (round toward +∞).
  • For non-integer x, ⌈x⌉ = ⌊x⌋ + 1; for integer x, both equal x.
  • x − 1 < ⌊x⌋ ≤ x ≤ ⌈x⌉ < x + 1 bounds both functions in terms of x.
  • Ceiling models 'round up to cover everything' (e.g. boxes needed for n items of capacity k is ⌈n/k⌉).

References