You are on page 1of 10

Floor and ceiling functions

From Wikipedia, the free encyclopedia

For other uses, see Floor (disambiguation) and Ceiling (disambiguation).
Floor and ceiling functions

Floor function

Ceiling function

In mathematics and computer science, the floor and ceiling functions map a real number to the
largest previous or the smallest followinginteger, respectively. More precisely, floor(x) =

is the

largest integer not greater than x and ceiling(x) =


is the smallest integer not less than x.


1 Notation

1.1 Examples


1.2 Typesetting

2 Definition and properties

2.1 Equivalences

10 Formulas for prime numbers o 3.o 2.7 Beatty sequence o 3.1 Mod operator o 3.5 Continuity o 2.3 Rounding o 3.12 Unsolved problem  4 Computer implementations 4.3 Quotients o 2.9 Riemann function (ζ) o 3.2 Quadratic reciprocity o 3.5 Number of digits o 3.2 Relations among the functions o 2.4 Truncation o 3.8 Euler's constant (γ) o 3.4 Nested divisions o 2.1 Spreadsheet software o  5 See also  6 Notes  7 References  8 External links .6 Series expansions  3 Applications o 3.6 Factors of factorials o 3.11 Solved problem o 3.

other computer languages commonly use notations like entier(x) (Algol). C++.9 −2.4 2.[7] In mathematics. and its value at x is called the integral part or integer part of x. Iverson introduced the names "floor" and "ceiling" and the corresponding notations his 1962 book A Programming Language. uses >. for floor. for negative values of x the latter terms are sometimes instead taken to be the value of the ceiling function. The floor function is also called the greatest integer or entier (French for "integer") function. there is another notation with reversed boldface or double brackets or just using normal reversed brackets ]x[. [4][5] and in Both notations are now used in mathematics. INT(x) (BASIC). The J Programming Language.7 −3 −2 0.9 2 3 0.4 2 3 2/5 = 0. i. The language APL uses ⌊x . and Python).3 −2 −2 −2 0 .Notation[edit] Carl Friedrich Gauss introduced the square bracket notation for the floor function in his third proof of quadratic reciprocity (1808). for ceiling and <.[8] The ceiling function is usually denoted by ceil(x) or ceiling(x) in non-APL computer languages that have a notation for this function.[2] This remained the standard[3] in mathematics until Kenneth E. Examples[edit] Sample value x Floor Ceiling Fractional part 12/5 = 2. or floor(x) (C. a follow on to APL that is designed to use standard keyboard symbols. the value of x rounded to an integer towards 0. is defined by the formula[11] For all x. R.. denoted by for real x. it can also be written with boldface or double brackets .[10] The fractional part sawtooth function.e. this [6] article follows Iverson.[9] In mathematics.

. negative.. Equivalences[edit] These formulas can be used to simplify expressions involving floors and ceilings. for any real x there are unique integers m and n satisfying Then and may also be taken as the definition of floor and ceiling.0 uses the same names:&lfloor. and n are integers. and zero). &rfloor.g. Unicode contains codepoints for these symbols at U+2308 – U+230B : ⌈x⌉. and &rceil.Typesetting[edit] The floor and ceiling function are usually typeset with left and right square brackets where the upper (for floor function) or lower (for ceiling function) horizontal bars are missing. Floor and ceiling may be defined by the set equations Since there is exactly one integer in a half-open interval of length one. m.. &lceil. in the LaTeX typesetting system these symbols can be specified with the \lfloor. .[12] In the language of order theory. ⌊x⌋. Definition and properties[edit] In the following formulas. e. \rfloor. that is. k. and is the set of integers (positive. the floor function is a residuated mapping.. part of a Galois connection: it is the upper adjoint of the function that embeds the integers into the reals. HTML 4.. and. x and y are real numbers. \lceil and \rceil commands in math mode.

i.These formulas show how adding integers to the arguments affect the functions: The above are not necessarily true if n is not an integer. since for integers n: Negating the argument switches floor and ceiling and changes the sign: and: . however: Relations among the functions[edit] It is clear from the definitions that with equality if and only if x is an integer.e. In fact.

Quotients[edit ] If m and n are integers and n ≠ 0. x mod y is idempotent: Also. If n is positive[13] .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: For fixed y. from the definitions.

If m i s positi ve[14] Fo r m = 2 th es e im ply More genera lly.[15] fo r positiv e m (S ee Her mite's identity ) .

positive. This is sometime a reciprocity law Nested divis For positive inte arbitrary real nu . the Since the right-h symmetrical in m this implies that More generally.The following can be used to convert floors to ceilings and vice-versa (m positive)[16] If m and n are p and coprime.

and of x for fixed y is of y. x m semicontinuous semi-continuous Series expan Since none of th this article are c have a power se and ceiling are n have uniformly c series expansion x mod y for fixed expansion[18] in particular {x} = .Continuity[ed None of the func article are contin linear. and functions. al integers. with d integers. is upper se and are lo continuous.

At points of disc to a value that is and the right. un part functions: fo Fourier series gi to x mod y = 0. A converges to the Using the formu gives Application .