Lably
Skip to content

Floor and ceiling functions

Nearest integers from a number

  • 10 min read
  • 4 chapters

Learn it on Lably

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.

Notation

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 and HTML entities:

  • U+2308 ⌈ LEFT CEILING (&lceil;, &LeftCeiling;)
  • U+2309 ⌉ RIGHT CEILING (&rceil;, &RightCeiling;)
  • U+230A ⌊ LEFT FLOOR (&LeftFloor;, &lfloor;)
  • U+230B ⌋ RIGHT FLOOR (&rfloor;, &RightFloor;)

In the LaTeX typesetting system, these symbols can be specified with the \lceil, \rceil, \lfloor, and \rfloor commands in math mode. LaTeX has supported UTF-8 since 2018, so the Unicode characters can now be used directly. Larger versions are\left\lceil, \right\rceil, \left\lfloor, and \right\rfloor.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Functions