In mathematics, the floor function is the function that takes a real number as input and returns the greatest integer less than or equal to , written or . Similarly, the ceiling function returns the least integer greater than or equal to , written or .Graham, Knuth, & Patashnik, Ch. 3.1

For example, for floor: , , and for ceiling: , and .

The floor of is also called the integral part, integer part, greatest integer, or entier of , and was historically denoted (among other notations).1) Luke Heaton, A Brief History of Mathematical Thought, 2015, (n.p.) 2) Albert A. Blank et al., Calculus: Differential Calculus, 1968, p. 259 3) John W. Warris, Horst Stocker, Handbook of mathematics and computational science, 1998, , p. 151 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 , .

Although and are equal for non-integer values of , and thus produce graphs that appear exactly alike, they differ when is an integer. For example, when , . However, if , then but .

+Examples x Floor Ceiling Fractional part 2 2 2 0 2.0001 2 3 0.0001 2 3 0.7182... 2.9 2 3 0.9 2.999 2 3 0.999 − −4 −3 0.8584... −2 −2 −2 0

Notation The integral part or integer part of a number ( 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 in his third proof of quadratic reciprocity (1808).Lemmermeyer, pp. 10, 23. This remained the standarde.g. Cassels, Hardy & Wright, and Ribenboim use Gauss's notation. Graham, Knuth & Patashnik, and Crandall & Pomerance use Iverson's. in mathematics until Kenneth E. Iverson introduced, in his 1962 book A Programming Language, the names "floor" and "ceiling" and the corresponding notations and .Iverson, p. 12.Higham, p. 25. (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 are used for floor, and reversed brackets or for ceiling.Mathwords: Floor Function.Mathwords: Ceiling Function

The fractional part is the sawtooth function, denoted by for real and defined by the formula Graham, Knuth, & Patashnik, p. 70.

For all x, .

These characters are provided in Unicode and HTML entities:

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

Definition and properties Given real numbers and , integers and and the set of integers , floor and ceiling may be defined by the equations

Since there is exactly one integer in a half-open interval of length one, for any real number , there are unique integers and satisfying the equation

where  and  may also be taken as the definition of floor and ceiling.

Equivalences These formulas can be used to simplify expressions involving floors and ceilings.Graham, Knuth, & Patashink, Ch. 3

In the language of order theory, the floor function is a residuated mapping, that is, part of a Galois connection: it is the upper adjoint of the function that embeds the integers into the reals.

These formulas show how adding an integer to the arguments affects the functions:

The above are never true if is not an integer; however, for every and , the following inequalities hold:

Monotonicity Both floor and ceiling functions are monotonically non-decreasing functions:

Relations among the functions It is clear from the definitions that with equality if and only if x is an integer, i.e.

In fact, for integers , both floor and ceiling functions are the identity:

Negating the argument switches floor and ceiling and changes the sign:

and:

Negating the argument complements the fractional part:

The floor, ceiling, and fractional part functions are idempotent:

The result of nested floor or ceiling functions is the innermost function:

due to the identity property for integers.

Quotients If and are integers and ,

If is positiveGraham, Knuth, & Patashnik, p. 73

If is positiveGraham, Knuth, & Patashnik, p. 85

For these imply

More generally,Graham, Knuth, & Patashnik, p. 85 and Ex. 3.15 for positive (See Hermite's identity)

The following can be used to convert floors to ceilings and vice versa (with being positive)Graham, Knuth, & Patashnik, Ex. 3.12

For all and strictly positive integers:Graham, Knuth, & Patashnik, p. 94.

which, for positive and coprime and , reduces to

and similarly for the ceiling and fractional part functions (still for positive and coprime and ),

Since the right-hand side of the general case is symmetrical in and , this implies that

More generally, if and are positive,

This is sometimes called a reciprocity law.Graham, Knuth, & Patashnik, p. 94

Division by positive integers gives rise to an interesting and sometimes useful property. Assuming ,

Similarly,

Indeed,

keeping in mind that The second equivalence involving the ceiling function can be proved similarly.

For being a positive integer with greater than . Then Problems and Solutions, The College Mathematics Journal, 56:4

where is the remainder of dividing by

Nested divisions For a positive integer , and arbitrary real numbers and :Graham, Knuth, & Patashnik, p. 71, apply theorem 3.10 with as input and the division by n as function

Continuity and series expansions None of the functions discussed in this article are continuous, but all are piecewise linear: the functions , , and have discontinuities at the integers.

is upper semi-continuous and and are lower semi-continuous.

Since none of the functions discussed in this article are continuous, none of them have a power series expansion. Since floor and ceiling are not periodic, they do not have uniformly convergent Fourier series expansions. The fractional part function has Fourier series expansionTitchmarsh, p. 15, Eq. 2.1.7

for not an integer.

At points of discontinuity, a Fourier series converges to a value that is the average of its limits on the left and the right, unlike the floor, ceiling and fractional part functions: for fixed and a multiple of the Fourier series given converges to , rather than to . At points of continuity the series converges to the true value.

Using the formula gives

for not an integer.

Applications

Mod operator

For an integer and a positive integer , the modulo operation, denoted by , gives the value of the remainder when is divided by . This definition can be extended to real and , , by the formula

Then it follows from the definition of floor function that this extended operation satisfies many natural properties. Notably, is always between 0 and , i.e.,

if is positive,

and if is negative,

Quadratic reciprocity Gauss's third proof of quadratic reciprocity, as modified by Eisenstein, has two basic steps.Lemmermeyer, § 1.4, Ex. 1.32–1.33Hardy & Wright, §§ 6.11–6.13

Let and be distinct positive odd prime numbers, and let

First, Gauss's lemma is used to show that the Legendre symbols are given by

The second step is to use a geometric argument to show that

Combining these formulas gives quadratic reciprocity in the form

There are formulas that use floor to express the quadratic character of small numbers mod odd primes :Lemmermeyer, p. 25

Rounding For an arbitrary real number , rounding to the nearest integer with tie breaking towards positive infinity is given by

rounding towards negative infinity is given as

If tie-breaking is away from 0, then the rounding function is

(where is the sign function), and rounding towards even can be expressed with the more cumbersome

which is the above expression for rounding towards positive infinity minus an integrality indicator for .

Rounding a real number to the nearest integer value forms a very basic type of quantizer – a uniform one. A typical (mid-tread) uniform quantizer with a quantization step size equal to some value can be expressed as

Number of digits The number of digits in base of a positive integer is

Number of strings without repeated characters The number of possible strings of arbitrary length that doesn't use any character twice is given by (See Formulas.)

where:

is the number of letters in the alphabet (e.g., 26 in English) the falling factorial denotes the number of strings of length that don't use any character twice. denotes the factorial of is Euler's number

For , this comes out to 1096259850353149530222034277.

Factors of factorials Let be a positive integer and a positive prime number. The exponent of the highest power of that divides is given by a version of Legendre's formulaHardy & Wright, Th. 416

where is the way of writing in base . This is a finite sum, since the floors are zero when .

Beatty sequence The Beatty sequence shows how every positive irrational number gives rise to a partition of the natural numbers into two sequences via the floor function.Graham, Knuth, & Patashnik, pp. 77–78

Euler's constant (γ) There are formulas for Euler's constant that involve the floor and ceiling, e.g.These formulas are from the Wikipedia article Euler's constant, which has many more.

and

Riemann zeta function (ζ) The fractional part function also shows up in integral representations of the Riemann zeta function. It is straightforward to prove (using integration by parts)Titchmarsh, p. 13 that if is any function with a continuous derivative in the closed interval ,

Letting for real part of greater than 1 and letting and be integers, and letting approach infinity gives

This formula is valid for all with real part greater than −1, (except , where there is a pole) and combined with the Fourier expansion for can be used to extend the zeta function to the entire complex plane and to prove its functional equation.Titchmarsh, pp.14–15

For in the critical strip ,

In 1947 van der Pol used this representation to construct an analogue computer for finding roots of the zeta function.Crandall & Pomerance, p. 391

Formulas for prime numbers The floor function appears in several formulas characterizing prime numbers. For example, since

it follows that a positive integer is a prime if and only ifCrandall & Pomerance, Ex. 1.3, p. 46. The infinite upper limit of the sum can be replaced with n. An equivalent condition is n > 1 is prime if and only if

One may also give formulas for producing the prime numbers. For example, let be the -th prime, and for any integer , define the real number by the sum

ThenHardy & Wright, § 22.3

A similar result is that there is a number (Mills' constant) with the property that

are all prime.Ribenboim, p. 186

There is also a number with the property that

are all prime.

Let be the number of primes less than or equal to . It is a straightforward deduction from Wilson's theorem thatRibenboim, p. 181

Also, if ,Crandall & Pomerance, Ex. 1.4, p. 46

None of the formulas in this section are of any practical use.Ribenboim, p. 180 says that "Despite the nil practical value of the formulas ... [they] may have some relevance to logicians who wish to understand clearly how various parts of arithmetic may be deduced from different axiomatzations ... "Hardy & Wright, pp. 344—345 "Any one of these formulas (or any similar one) would attain a different status if the exact value of the number α ... could be expressed independently of the primes. There seems no likelihood of this, but it cannot be ruled out as entirely impossible."

Solved problems Ramanujan submitted these problems to the Journal of the Indian Mathematical Society.Ramanujan, Question 723, Papers p. 332

If is a positive integer, prove that

Some generalizations to the above floor function identities have been proven.

Unsolved problem The study of Waring's problem has led to an unsolved problem: