Floor and ceiling functions
In mathematics and computer science, the floor and ceiling functions map a real number to the largest previous or the smallest following integer, respectively. More precisely, floor(x) =
is the largest integer not greater than x and ceiling(x) =
is the smallest integer not less than x.
Notation
Carl Friedrich Gauss introduced the square bracket notation
for the floor function in his third proof of quadratic reciprocity (1808).
This remained the standard in mathematics until Kenneth E. Iverson introduced the names "floor" and "ceiling" and the corresponding notations
and
in his 1962 book A Programming Language. Both notations are now used in mathematics; this article follows Iverson.
The floor function is also called the greatest integer or entier (French for "integer") function, and its value at x is called the integral part or integer part of x; for negative values of x the latter terms are sometimes instead taken to be the value of the ceiling function, i.e., the value of x rounded to an integer towards 0. The language APL uses ⌊x
; other computer languages commonly use notations like entier(x)
(ALGOL), INT(x)
(BASIC), or floor(x)
(C, C++, R, and Python). In mathematics, it can also be written with boldface or double brackets
.