functions on the integers
Floor and Ceiling Functions
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
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:
Worked Examples
3.7 lies between the integers 3 and 4. Floor rounds down to 3.
Ceiling rounds up to 4.
Answer: ⌊3.7⌋ = 3 and ⌈3.7⌉ = 4.
Practice Problems
Evaluate ⌊7.9⌋ and ⌈7.1⌉.
Evaluate ⌊-5⌋ and ⌈-5⌉.
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
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⌉).
Mathematics