In mathematics and computer science, the floor function is the function that takes as input a real number x, and gives as output the greatest integer less than or equal to x, denoted ⌊x⌋ or floor(x). Similarly, the ceiling function maps x to the least integer greater than or equal to x, denoted ⌈x⌉ or ceil(x).
For example (floor), ⌊2.4⌋ = 2, ⌊−2.4⌋ = −3, and for ceiling; ⌈2.4⌉ = 3, and ⌈−2.4⌉ = −2.
Historically, the floor of x has been–and still is–called the integral part or integer part of x, often denoted [x] (as well as a variety of other notations). However, the same term, integer part, is also used for truncation towards zero, which differs from the floor function for negative numbers.
For n an integer, ⌊n⌋ = ⌈n⌉ = [n] = n.
The integral part or integer part of a number (partie entière in the original) was first defined in 1798 by Adrien-Marie Legendre in his proof of the Legendre's formula.
Carl Friedrich Gauss introduced the square bracket notation [x] in his third proof of quadratic reciprocity (1808). This remained the standard in mathematics until Kenneth E. Iverson introduced, in his 1962 book A Programming Language, the names "floor" and "ceiling" and the corresponding notations ⌊x⌋ and ⌈x⌉. (Iverson used square brackets for a different purpose, the Iverson bracket notation.) Both notations are now used in mathematics, although Iverson's notation will be followed in this article.
In some sources, boldface or double brackets ⟦x⟧ are used for floor, and reversed brackets ⟧x⟦ or ]x[ for ceiling.
The fractional part is the sawtooth function, denoted by {x} for real x and defined by the formula
{x} = x − ⌊x⌋
For all x,
0 ≤ {x} < 1.
These characters are provided in Unicode:
In the LaTeX typesetting system, these symbols can be specified with the and commands in math mode, and extended in size using and as needed.
Some authors define [x] as the round-toward-zero function, so [2.4] = 2 and [−2.4] = −2, and call it the "integer part". This is truncation to zero significant digits.