Recipe
Evaluate floor and ceiling of a real number
Use when: you need \lfloor x \rfloor or \lceil x \rceil for one specific real number x, especially a negative one
Goal: the exact integer values of floor(x) and ceiling(x), without a sign error
Taught in Floor and ceiling
Quick recipe
-
1
If x has no fractional part, both floor(x) and ceiling(x) equal x itself, and there is nothing left to round.
Example
x = 4: \lfloor 4 \rfloor = 4 and \lceil 4 \rceil = 4.
Why: an integer is already the greatest integer at or below itself, and the least integer at or above itself.
-
2
Find the integer n with n < x < n+1. For a positive x, n is the truncated (decimal-dropped) part. For a negative x, truncating gives the WRONG value.
Example
For x = -4.7: dropping the decimal gives -4, but the correct n is -5, since -5 < -4.7 < -4.
- x is positive — n is obtained by dropping the decimal digits directly.
- x is negative and not an integer — n is one less (more negative) than the truncated value, not the truncated value itself.
Why: floor and ceiling are decided by which integer is genuinely smaller or larger than x, not by which digits happen to get dropped.
-
3
floor(x) equals n, the lower neighbor; ceiling(x) equals n+1, the upper neighbor.
Example
For x=-4.7, n=-5, so \lfloor -4.7 \rfloor = -5 and \lceil -4.7 \rceil = -5+1 = -4.
⚡ Shortcut
The same floor operation counts positive multiples of k up to N without listing them: the count is \lfloor N/k \rfloor. For k=7, N=100: \lfloor 100/7 \rfloor = 14.
Why: n is by construction the greatest integer not exceeding x, and n+1 is then the least integer that exceeds x.
Common mistakes
- Truncating the decimal part of a negative number and reporting that as the floor, when it is actually the ceiling.
- Mixing up which neighbor is floor and which is ceiling.
- Forgetting the already-an-integer case, and reporting a neighbor that does not equal x.
- Applying the floor-counting shortcut to a range that does not start at 1, without adjusting the count.