Floor and ceiling functions
In mathematics, the floor function is the function that takes a real number x as input and returns the greatest integer less than or equal to x, written ⌊x⌋ or floor(x). Similarly, the ceiling function returns the least integer greater than or equal to x, written ⌈x⌉ or ceil(x).
For example, for floor: ⌊2.4⌋ = 2, ⌊−2.4⌋ = −3, and for ceiling: ⌈2.4⌉ = 3, and ⌈−2.4⌉ = −2.
The floor of x is also called the integral part, integer part, greatest integer, or entier of x, and was historically denoted [x] (among other notations). However, the term "integer part" is ambiguous, as it can also mean truncation towards zero, which differs from the floor function for negative numbers.
For an integer n, ⌊n⌋ = ⌈n⌉ = n.
Although floor(x + 1) and ceil(x) are equal for non-integer values of x, and thus produce graphs that appear exactly alike, they differ when x is an integer. For example, when x = 2.0001, ⌊2.0001 + 1⌋ = ⌈2.0001⌉ = 3. However, if x = 2, then ⌊2 + 1⌋ = 3 but ⌈2⌉ = 2.
| x | Floor ⌊x⌋ | Ceiling ⌈x⌉ | Fractional part {x} |
|---|---|---|---|
| 2 | 2 | 2 | 0 |
| 2.0001 | 2 | 3 | 0.0001 |
| e | 2 | 3 | 0.7182... |
| 2.9 | 2 | 3 | 0.9 |
| 2.999 | 2 | 3 | 0.999 |
| −π | −4 | −3 | 0.8584... |
| −2 | −2 | −2 | 0 |