Ceiling Function
   HOME

TheInfoList



OR:

In
mathematics Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
and
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
, the floor function is the
function Function or functionality may refer to: Computing * Function key, a type of key on computer keyboards * Function model, a structured representation of processes in a system * Function object or functor or functionoid, a concept of object-oriente ...
that takes as input a
real number In mathematics, a real number is a number that can be used to measure a ''continuous'' one-dimensional quantity such as a distance, duration or temperature. Here, ''continuous'' means that values can have arbitrarily small variations. Every real ...
, and gives as output the greatest
integer An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign (−1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
less than or equal to , denoted or . Similarly, the ceiling function maps to the least integer greater than or equal to , denoted or . For example, , , , and . Historically, the floor of has been–and still is–called the integral part or integer part of , often denoted (as well as a variety of other notations). Some authors may define the integral part as if is nonnegative, and otherwise: for example, and . The operation of
truncation In mathematics and computer science, truncation is limiting the number of digits right of the decimal point. Truncation and floor function Truncation of positive real numbers can be done using the floor function. Given a number x \in \mathbb ...
generalizes this to a specified number of digits: truncation to zero significant digits is the same as the integer part. For an integer, .


Notation

The ''integral part'' or ''integer part'' of a number ( in the original) was first defined in 1798 by
Adrien-Marie Legendre Adrien-Marie Legendre (; ; 18 September 1752 – 9 January 1833) was a French mathematician who made numerous contributions to mathematics. Well-known and important concepts such as the Legendre polynomials and Legendre transformation are named ...
in his proof of the
Legendre's formula In mathematics, Legendre's formula gives an expression for the exponent of the largest power of a prime ''p'' that divides the factorial ''n''!. It is named after Adrien-Marie Legendre. It is also sometimes known as de Polignac's formula, aft ...
.
Carl Friedrich Gauss Johann Carl Friedrich Gauss (; german: Gauß ; la, Carolus Fridericus Gauss; 30 April 177723 February 1855) was a German mathematician and physicist who made significant contributions to many fields in mathematics and science. Sometimes refer ...
introduced the square bracket notation in his third proof of
quadratic reciprocity In number theory, the law of quadratic reciprocity is a theorem about modular arithmetic that gives conditions for the solvability of quadratic equations modulo prime numbers. Due to its subtlety, it has many formulations, but the most standard st ...
(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 and . (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. Sometimes is taken to mean the round-toward-zero function. The
fractional part The fractional part or decimal part of a non‐negative real number x is the excess beyond that number's integer part. If the latter is defined as the largest integer not greater than , called floor of or \lfloor x\rfloor, its fractional part can ...
is the
sawtooth function The sawtooth wave (or saw wave) is a kind of non-sinusoidal waveform. It is so named based on its resemblance to the teeth of a plain-toothed saw with a zero rake angle. A single sawtooth, or an intermittently triggered sawtooth, is called ...
, denoted by for real and defined by the formula : For all ''x'', :. These characters are provided in Unicode: * * * * In the
LaTeX Latex is an emulsion (stable dispersion) of polymer microparticles in water. Latexes are found in nature, but synthetic latexes are common as well. In nature, latex is found as a milky fluid found in 10% of all flowering plants (angiosperms ...
typesetting system, these symbols can be specified with the and commands in math mode, and extended in size using \left\lfloor, \right\rfloor, \left\lceil and \right\rceil as needed.


Definition and properties

Given real numbers ''x'' and ''y'', integers ''k'', ''m'', ''n'' and the set of
integer An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign (−1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
s \mathbb, floor and ceiling may be defined by the equations : \lfloor x \rfloor=\max \, : \lceil x \rceil=\min \. Since there is exactly one integer in a
half-open interval In mathematics, a (real) interval is a set of real numbers that contains all real numbers lying between any two numbers of the set. For example, the set of numbers satisfying is an interval which contains , , and all numbers in between. Othe ...
of length one, for any real number ''x'', there are unique integers ''m'' and ''n'' satisfying the equation :x-1 where \lfloor x \rfloor = m and \lceil x \rceil = n may also be taken as the definition of floor and ceiling.


Equivalences

These formulas can be used to simplify expressions involving floors and ceilings. : \begin \lfloor x \rfloor = m &\;\;\mbox &m &\le x < m+1,\\ \lceil x \rceil = n &\;\;\mbox &n -1 &< x \le n,\\ \lfloor x \rfloor = m &\;\;\mbox &x-1 &< m \le x,\\ \lceil x \rceil = n &\;\;\mbox &x &\le n < x+1. \end In the language of
order theory Order theory is a branch of mathematics that investigates the intuitive notion of order using binary relations. It provides a formal framework for describing statements such as "this is less than that" or "this precedes that". This article intr ...
, the floor function is a
residuated mapping In mathematics, the concept of a residuated mapping arises in the theory of partially ordered sets. It refines the concept of a monotone function. If ''A'', ''B'' are posets, a function ''f'': ''A'' → ''B'' is defined to be monotone if it is o ...
, that is, part of a
Galois connection In mathematics, especially in order theory, a Galois connection is a particular correspondence (typically) between two partially ordered sets (posets). Galois connections find applications in various mathematical theories. They generalize the funda ...
: it is the upper adjoint of the function that embeds the integers into the reals. : \begin x These formulas show how adding integers to the arguments affects the functions: : \begin \lfloor x+n \rfloor &= \lfloor x \rfloor+n,\\ \lceil x+n \rceil &= \lceil x \rceil+n,\\ \ &= \. \end The above are never true if ''n'' is not an integer; however, for every and , the following inequalities hold: :\begin \lfloor x \rfloor + \lfloor y \rfloor &\leq \lfloor x + y \rfloor \leq \lfloor x \rfloor + \lfloor y \rfloor + 1,\\ \lceil x \rceil + \lceil y \rceil -1 &\leq \lceil x + y \rceil \leq \lceil x \rceil + \lceil y \rceil. \end


Monotonicity

Both floor and ceiling functions are the monotonically non-decreasing function: : \begin x_ \le x_ &\Rightarrow \lfloor x_ \rfloor \le \lfloor x_ \rfloor, \\ x_ \le x_ &\Rightarrow \lceil x_ \rceil \le \lceil x_ \rceil. \end


Relations among the functions

It is clear from the definitions that :\lfloor x \rfloor \le \lceil x \rceil,   with equality if and only if ''x'' is an integer, i.e. :\lceil x \rceil - \lfloor x \rfloor = \begin 0&\mbox x\in \mathbb\\ 1&\mbox x\not\in \mathbb \end In fact, for integers ''n'', both floor and ceiling functions are the
identity Identity may refer to: * Identity document * Identity (philosophy) * Identity (social science) * Identity (mathematics) Arts and entertainment Film and television * ''Identity'' (1987 film), an Iranian film * ''Identity'' (2003 film), ...
: :\lfloor n \rfloor = \lceil n \rceil = n. Negating the argument switches floor and ceiling and changes the sign: : \begin \lfloor x \rfloor +\lceil -x \rceil &= 0 \\ -\lfloor x \rfloor &= \lceil -x \rceil \\ -\lceil x \rceil &= \lfloor -x \rfloor \end and: :\lfloor x \rfloor + \lfloor -x \rfloor = \begin 0&\text x\in \mathbb\\ -1&\text x\not\in \mathbb, \end :\lceil x \rceil + \lceil -x \rceil = \begin 0&\text x\in \mathbb\\ 1&\text x\not\in \mathbb. \end Negating the argument complements the fractional part: :\ + \ = \begin 0&\text x\in \mathbb\\ 1&\text x\not\in \mathbb. \end The floor, ceiling, and fractional part functions are
idempotent Idempotence (, ) is the property of certain operations in mathematics and computer science whereby they can be applied multiple times without changing the result beyond the initial application. The concept of idempotence arises in a number of pl ...
: : \begin \Big\lfloor \lfloor x \rfloor \Big\rfloor &= \lfloor x \rfloor, \\ \Big\lceil \lceil x \rceil \Big\rceil &= \lceil x \rceil, \\ \Big\ &= \. \end The result of nested floor or ceiling functions is the innermost function: : \begin \Big\lfloor \lceil x \rceil \Big\rfloor &= \lceil x \rceil, \\ \Big\lceil \lfloor x \rfloor \Big\rceil &= \lfloor x \rfloor \end due to the identity property for integers.


Quotients

If ''m'' and ''n'' are integers and ''n'' ≠ 0, :0 \le \left \ \le 1-\frac. If ''n'' is a positive integer :\left\lfloor\frac\right\rfloor = \left\lfloor\frac\right\rfloor, :\left\lceil\frac\right\rceil = \left\lceil\frac\right\rceil. If ''m'' is positive :n=\left\lceil\frac\right\rceil + \left\lceil\frac\right\rceil +\dots+\left\lceil\frac\right\rceil, :n=\left\lfloor\frac\right\rfloor + \left\lfloor\frac\right\rfloor +\dots+\left\lfloor\frac\right\rfloor. For ''m'' = 2 these imply :n= \left\lfloor \frac\right \rfloor + \left\lceil\frac\right \rceil. More generally, for positive ''m'' (See
Hermite's identity In mathematics, Hermite's identity, named after Charles Hermite, gives the value of a summation involving the floor function. It states that for every real number ''x'' and for every positive integer ''n'' the following identity holds:. : \sum_^\ ...
) :\lceil mx \rceil =\left\lceil x\right\rceil + \left\lceil x-\frac\right\rceil +\dots+\left\lceil x-\frac\right\rceil, :\lfloor mx \rfloor=\left\lfloor x\right\rfloor + \left\lfloor x+\frac\right\rfloor +\dots+\left\lfloor x+\frac\right\rfloor. The following can be used to convert floors to ceilings and vice versa (''m'' positive) :\left\lceil \frac \right\rceil = \left\lfloor \frac \right\rfloor = \left\lfloor \frac \right\rfloor + 1, :\left\lfloor \frac \right\rfloor = \left\lceil \frac \right\rceil = \left\lceil \frac \right\rceil - 1, For all ''m'' and ''n'' strictly positive integers: :\sum_^ \left\lfloor \frac \right\rfloor = \frac2, which, for positive and
coprime In mathematics, two integers and are coprime, relatively prime or mutually prime if the only positive integer that is a divisor of both of them is 1. Consequently, any prime number that divides does not divide , and vice versa. This is equivale ...
''m'' and ''n'', reduces to :\sum_^ \left\lfloor \frac \right\rfloor = \frac(m - 1)(n - 1) , and similarly for the ceiling and fractional part functions (still for positive and
coprime In mathematics, two integers and are coprime, relatively prime or mutually prime if the only positive integer that is a divisor of both of them is 1. Consequently, any prime number that divides does not divide , and vice versa. This is equivale ...
''m'' and ''n''), :\sum_^ \left\lceil \frac \right\rceil = \frac(m + 1)(n - 1), :\sum_^ \left\ = \frac(n - 1). Since the right-hand side of the general case is symmetrical in ''m'' and ''n'', this implies that :\left\lfloor \frac \right \rfloor + \left\lfloor \frac \right \rfloor + \dots + \left\lfloor \frac \right \rfloor = \left\lfloor \frac \right \rfloor + \left\lfloor \frac \right \rfloor + \dots + \left\lfloor \frac \right \rfloor. More generally, if ''m'' and ''n'' are positive, :\begin &\left\lfloor \frac \right \rfloor + \left\lfloor \frac \right \rfloor + \left\lfloor \frac \right \rfloor + \dots + \left\lfloor \frac \right \rfloor\\= &\left\lfloor \frac \right \rfloor + \left\lfloor \frac \right \rfloor + \left\lfloor \frac \right \rfloor + \cdots + \left\lfloor \frac \right \rfloor. \end This is sometimes called a
reciprocity law In mathematics, a reciprocity law is a generalization of the law of quadratic reciprocity to arbitrary monic irreducible polynomials f(x) with integer coefficients. Recall that first reciprocity law, quadratic reciprocity, determines when an irr ...
.


Nested divisions

For positive integer ''n'', and arbitrary real numbers ''m'',''x'': : \left\lfloor \frac \right\rfloor = \left\lfloor \frac \right\rfloor : \left\lceil \frac \right\rceil = \left\lceil \frac \right\rceil.


Continuity and series expansions

None of the functions discussed in this article are
continuous Continuity or continuous may refer to: Mathematics * Continuity (mathematics), the opposing concept to discreteness; common examples include ** Continuous probability distribution or random variable in probability and statistics ** Continuous ...
, but all are piecewise linear: the functions \lfloor x \rfloor, \lceil x \rceil, and \ have discontinuities at the integers. \lfloor x \rfloor  is
upper semi-continuous In mathematical analysis, semicontinuity (or semi-continuity) is a property of extended real-valued functions that is weaker than continuity. An extended real-valued function f is upper (respectively, lower) semicontinuous at a point x_0 if, r ...
and  \lceil x \rceil  and \  are lower semi-continuous. Since none of the functions discussed in this article are continuous, none of them have a
power series In mathematics, a power series (in one variable) is an infinite series of the form \sum_^\infty a_n \left(x - c\right)^n = a_0 + a_1 (x - c) + a_2 (x - c)^2 + \dots where ''an'' represents the coefficient of the ''n''th term and ''c'' is a const ...
expansion. Since floor and ceiling are not periodic, they do not have uniformly convergent
Fourier series A Fourier series () is a summation of harmonically related sinusoidal functions, also known as components or harmonics. The result of the summation is a periodic function whose functional form is determined by the choices of cycle length (or ''p ...
expansions. The fractional part function has Fourier series expansion :\= \frac - \frac \sum_^\infty \frac 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 ''y'' fixed and ''x'' a multiple of ''y'' the Fourier series given converges to ''y''/2, rather than to ''x'' mod ''y'' = 0. At points of continuity the series converges to the true value. Using the formula floor(x) = x − gives :\lfloor x\rfloor = x - \frac + \frac \sum_^\infty \frac for not an integer.


Applications


Mod operator

For an integer ''x'' and a positive integer ''y'', the
modulo operation In computing, the modulo operation returns the remainder or signed remainder of a division, after one number is divided by another (called the '' modulus'' of the operation). Given two positive numbers and , modulo (often abbreviated as ) is th ...
, denoted by ''x'' mod ''y'', gives the value of the remainder when ''x'' is divided by ''y''. This definition can be extended to real ''x'' and ''y'', ''y'' ≠ 0, by the formula :x \bmod y = x-y\left\lfloor \frac\right\rfloor. Then it follows from the definition of floor function that this extended operation satisfies many natural properties. Notably, ''x'' mod ''y'' is always between 0 and ''y'', i.e., if ''y'' is positive, :0 \le x \bmod y and if ''y'' is negative, :0 \ge x \bmod y >y.


Quadratic reciprocity

Gauss's third proof of
quadratic reciprocity In number theory, the law of quadratic reciprocity is a theorem about modular arithmetic that gives conditions for the solvability of quadratic equations modulo prime numbers. Due to its subtlety, it has many formulations, but the most standard st ...
, as modified by Eisenstein, has two basic steps. Let ''p'' and ''q'' be distinct positive odd prime numbers, and let :m = \frac, n = \frac. First, Gauss's lemma is used to show that the
Legendre symbol In number theory, the Legendre symbol is a multiplicative function with values 1, −1, 0 that is a quadratic character modulo an odd prime number ''p'': its value at a (nonzero) quadratic residue mod ''p'' is 1 and at a non-quadratic residu ...
s are given by :\left(\frac\right) = (-1)^ and :\left(\frac\right) = (-1)^. The second step is to use a geometric argument to show that :\left\lfloor\frac\right\rfloor +\left\lfloor\frac\right\rfloor +\dots +\left\lfloor\frac\right\rfloor +\left\lfloor\frac\right\rfloor +\left\lfloor\frac\right\rfloor +\dots +\left\lfloor\frac\right\rfloor = mn. Combining these formulas gives quadratic reciprocity in the form :\left(\frac\right) \left(\frac\right) = (-1)^=(-1)^. There are formulas that use floor to express the quadratic character of small numbers mod odd primes ''p'': :\left(\frac\right) = (-1)^, :\left(\frac\right) = (-1)^.


Rounding

For an arbitrary real number x,
rounding Rounding means replacing a number with an approximate value that has a shorter, simpler, or more explicit representation. For example, replacing $ with $, the fraction 312/937 with 1/3, or the expression with . Rounding is often done to obta ...
x to the nearest integer with tie breaking towards positive infinity is given by \text(x)=\left\lfloor x+\tfrac\right\rfloor = \left\lceil \tfrac2 \right\rceil; rounding towards negative infinity is given as \text(x)=\left\lceil x-\tfrac\right\rceil = \left\lfloor \tfrac2 \right\rfloor. If tie-breaking is away from 0, then the rounding function is \text(x) = \sgn(x)\left\lfloor, x, +\tfrac\right\rfloor (see
sign function In mathematics, the sign function or signum function (from '' signum'', Latin for "sign") is an odd mathematical function that extracts the sign of a real number. In mathematical expressions the sign function is often represented as . To avoi ...
), and rounding towards even can be expressed with the more cumbersome \lfloor x\rceil=\left\lfloor x+\tfrac\right\rfloor+\left\lceil\tfrac4\right\rceil-\left\lfloor\tfrac4\right\rfloor-1, which is the above expression for rounding towards positive infinity \text(x) minus an
integrality In commutative algebra, an element ''b'' of a commutative ring ''B'' is said to be integral over ''A'', a subring of ''B'', if there are ''n'' ≥ 1 and ''a'j'' in ''A'' such that :b^n + a_ b^ + \cdots + a_1 b + a_0 = 0. That is to say, ''b'' ...
indicator Indicator may refer to: Biology * Environmental indicator of environmental health (pressures, conditions and responses) * Ecological indicator of ecosystem health (ecological processes) * Health indicator, which is used to describe the health ...
for \tfrac4.


Number of digits

The number of digits in base ''b'' of a positive integer ''k'' is :\lfloor \log_ \rfloor + 1 = \lceil \log_ \rceil .


Number of strings without repeated characters

The number of possible
strings String or strings may refer to: *String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects Arts, entertainment, and media Films * ''Strings'' (1991 film), a Canadian anim ...
of arbitrary length that don't use any character twice is given by :(n)_0 + \cdots + (n)_n = \lfloor e n! \rfloor where: * > 0 is the number of letters in the alphabet (e.g., 26 in
English English usually refers to: * English language * English people English may also refer to: Peoples, culture, and language * ''English'', an adjective for something of, from, or related to England ** English national ide ...
) * the
falling factorial In mathematics, the falling factorial (sometimes called the descending factorial, falling sequential product, or lower factorial) is defined as the polynomial :\begin (x)_n = x^\underline &= \overbrace^ \\ &= \prod_^n(x-k+1) = \prod_^(x-k) \,. \e ...
(n)_k = n(n-1)\cdots(n-k+1) denotes the number of strings of length that don't use any character twice. * ! denotes the
factorial In mathematics, the factorial of a non-negative denoted is the product of all positive integers less than or equal The factorial also equals the product of n with the next smaller factorial: \begin n! &= n \times (n-1) \times (n-2) \t ...
of * = 2.718… is
Euler's number The number , also known as Euler's number, is a mathematical constant approximately equal to 2.71828 that can be characterized in many ways. It is the base of a logarithm, base of the natural logarithms. It is the Limit of a sequence, limit ...
For = 26, this comes out to 1096259850353149530222034277.


Factors of factorials

Let ''n'' be a positive integer and ''p'' a positive prime number. The exponent of the highest power of ''p'' that divides ''n''! is given by a version of
Legendre's formula In mathematics, Legendre's formula gives an expression for the exponent of the largest power of a prime ''p'' that divides the factorial ''n''!. It is named after Adrien-Marie Legendre. It is also sometimes known as de Polignac's formula, aft ...
:\left\lfloor\frac\right\rfloor + \left\lfloor\frac\right\rfloor + \left\lfloor\frac\right\rfloor + \dots = \frac where n = \sum_a_kp^k is the way of writing ''n'' in base ''p''. This is a finite sum, since the floors are zero when ''p''''k'' > ''n''.


Beatty sequence

The
Beatty sequence In mathematics, a Beatty sequence (or homogeneous Beatty sequence) is the sequence of integers found by taking the floor of the positive multiples of a positive irrational number. Beatty sequences are named after Samuel Beatty, who wrote about th ...
shows how every positive
irrational number In mathematics, the irrational numbers (from in- prefix assimilated to ir- (negative prefix, privative) + rational) are all the real numbers that are not rational numbers. That is, irrational numbers cannot be expressed as the ratio of two integ ...
gives rise to a partition of the
natural number In mathematics, the natural numbers are those numbers used for counting (as in "there are ''six'' coins on the table") and ordering (as in "this is the ''third'' largest city in the country"). Numbers used for counting are called ''Cardinal n ...
s into two sequences via the floor function.


Euler's constant (γ)

There are formulas for
Euler's constant Euler's constant (sometimes also called the Euler–Mascheroni constant) is a mathematical constant usually denoted by the lowercase Greek letter gamma (). It is defined as the limiting difference between the harmonic series and the natural ...
γ = 0.57721 56649 ... that involve the floor and ceiling, e.g. :\gamma =\int_1^\infty\left(-\right)\,dx, :\gamma = \lim_ \frac \sum_^n \left( \left \lceil \frac \right \rceil - \frac \right), and : \gamma = \sum_^\infty (-1)^k \frac = \tfrac12-\tfrac13 + 2\left(\tfrac14 - \tfrac15 + \tfrac16 - \tfrac17\right) + 3\left(\tfrac18 - \cdots - \tfrac1\right) + \cdots


Riemann zeta function (ζ)

The fractional part function also shows up in integral representations of the
Riemann zeta function The Riemann zeta function or Euler–Riemann zeta function, denoted by the Greek letter (zeta), is a mathematical function of a complex variable defined as \zeta(s) = \sum_^\infty \frac = \frac + \frac + \frac + \cdots for \operatorname(s) > ...
. It is straightforward to prove (using integration by parts) that if \phi(x) is any function with a continuous derivative in the closed interval 'a'', ''b'' :\sum_\phi(n) = \int_a^b\phi(x) \, dx + \int_a^b\left(\-\tfrac12\right)\phi'(x) \, dx + \left(\-\tfrac12\right)\phi(a) - \left(\-\tfrac12\right)\phi(b). Letting \phi(n)=^ for
real part In mathematics, a complex number is an element of a number system that extends the real numbers with a specific element denoted , called the imaginary unit and satisfying the equation i^= -1; every complex number can be expressed in the form ...
of ''s'' greater than 1 and letting ''a'' and ''b'' be integers, and letting ''b'' approach infinity gives :\zeta(s) = s\int_1^\infty\frac\,dx + \frac + \frac 1 2. This formula is valid for all ''s'' with real part greater than −1, (except ''s'' = 1, 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. For ''s'' = ''σ'' + ''it'' in the critical strip 0 < ''σ'' < 1, :\zeta(s)=s\int_^\infty e^(\lfloor e^\omega\rfloor - e^\omega)e^\,d\omega. In 1947
van der Pol Van der Pol (also "Van de Pol", "Van de Poll", "Van den Pol" or "Van Pol") is a Dutch language, Dutch, toponymic surname, originally meaning "from the raised land".if and only if In logic and related fields such as mathematics and philosophy, "if and only if" (shortened as "iff") is a biconditional logical connective between statements, where either both statements are true or both are false. The connective is bicondi ...
:\sum_^\left(\left\lfloor\frac\right\rfloor-\left\lfloor\frac\right\rfloor\right) = 2. One may also give formulas for producing the prime numbers. For example, let ''p''''n'' be the ''n''-th prime, and for any integer ''r'' > 1, define the real number ''α'' by the sum :\alpha = \sum_^\infty p_m r^. Then :p_n = \left\lfloor r^\alpha \right\rfloor - r^\left\lfloor r^\alpha\right\rfloor. A similar result is that there is a number ''θ'' = 1.3064... (
Mills' constant In number theory, Mills' constant is defined as the smallest positive real number ''A'' such that the floor function of the double exponential function : \lfloor A^ \rfloor is a prime number for all natural numbers ''n''. This constant is named ...
) with the property that :\left\lfloor \theta^3 \right\rfloor, \left\lfloor \theta^9 \right\rfloor, \left\lfloor \theta^ \right\rfloor, \dots are all prime.Ribenboim, p. 186 There is also a number ''ω'' = 1.9287800... with the property that :\left\lfloor 2^\omega\right\rfloor, \left\lfloor 2^ \right\rfloor, \left\lfloor 2^ \right\rfloor, \dots are all prime. Let (''x'') be the number of primes less than or equal to ''x''. It is a straightforward deduction from
Wilson's theorem In algebra and number theory, Wilson's theorem states that a natural number ''n'' > 1 is a prime number if and only if the product of all the positive integers less than ''n'' is one less than a multiple of ''n''. That is (using the notations of m ...
that :\pi(n) = \sum_^n\left\lfloor\frac - \left\lfloor\frac\right\rfloor\right\rfloor. Also, if ''n'' ≥ 2, :\pi(n) = \sum_^n \left\lfloor \frac\right\rfloor. None of the formulas in this section are of any practical use.


Solved problems

Ramanujan submitted these problems to the ''Journal of the Indian Mathematical Society''. If ''n'' is a positive integer, prove that
  1. \left\lfloor\tfrac\right\rfloor + \left\lfloor\tfrac\right\rfloor + \left\lfloor\tfrac\right\rfloor = \left\lfloor\tfrac\right\rfloor + \left\lfloor\tfrac\right\rfloor,
  2. \left\lfloor\tfrac12 + \sqrt\right\rfloor = \left\lfloor\tfrac12 + \sqrt\right\rfloor,
  3. \left\lfloor\sqrt+ \sqrt\right\rfloor = \left\lfloor \sqrt\right\rfloor.
Some generalizations to the above floor function identities have been proven.


Unsolved problem

The study of
Waring's problem In number theory, Waring's problem asks whether each natural number ''k'' has an associated positive integer ''s'' such that every natural number is the sum of at most ''s'' natural numbers raised to the power ''k''. For example, every natural numb ...
has led to an unsolved problem: Are there any positive integers ''k'' ≥ 6 such that :3^k-2^k\left\lfloor \left(\tfrac 3 2\right)^k \right\rfloor > 2^k-\left\lfloor \left(\tfrac 3 2\right)^k \right\rfloor -2 ?
Mahler Gustav Mahler (; 7 July 1860 – 18 May 1911) was an Austro-Bohemian Romantic composer, and one of the leading conductors of his generation. As a composer he acted as a bridge between the 19th-century Austro-German tradition and the modernism ...
has proved there can only be a finite number of such ''k''; none are known.


Computer implementations

In most programming languages, the simplest method to convert a floating point number to an integer does not do floor or ceiling, but
truncation In mathematics and computer science, truncation is limiting the number of digits right of the decimal point. Truncation and floor function Truncation of positive real numbers can be done using the floor function. Given a number x \in \mathbb ...
. The reason for this is historical, as the first machines used
ones' complement The ones' complement of a binary number is the value obtained by inverting all the bits in the binary representation of the number (swapping 0s and 1s). The name "ones' complement" (''note this is possessive of the plural "ones", not of a sing ...
and truncation was simpler to implement (floor is simpler in
two's complement Two's complement is a mathematical operation to reversibly convert a positive binary number into a negative binary number with equivalent (but negative) value, using the binary digit with the greatest place value (the leftmost bit in big- endian ...
). FORTRAN was defined to require this behavior and thus almost all processors implement conversion this way. Some consider this to be an unfortunate historical design decision that has led to bugs handling negative offsets and graphics on the negative side of the origin. A bit-wise right-shift of a signed integer x by n is the same as \left\lfloor \frac \right\rfloor. Division by a power of 2 is often written as a right-shift, not for optimization as might be assumed, but because the floor of negative results is required. Assuming such shifts are "premature optimization" and replacing them with division can break software. Many programming languages (including C,
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
, C#,
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
,
PHP PHP is a general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementation is now produced by The PHP Group. ...
, R, and
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
) provide standard functions for floor and ceiling, usually called floor and ceil, or less commonly ceiling. The language APL uses ⌊x for floor. The
J Programming Language The J programming language, developed in the early 1990s by Kenneth E. Iverson and Roger Hui, is an array programming language based primarily on APL (also by Iverson). To avoid repeating the APL special-character problem, J uses only the basic ...
, a follow-on to APL that is designed to use standard keyboard symbols, uses <. for floor and >. for ceiling.
ALGOL ALGOL (; short for "Algorithmic Language") is a family of imperative computer programming languages originally developed in 1958. ALGOL heavily influenced many other languages and was the standard method for algorithm description used by the ...
usesentier for floor. In
Microsoft Excel Microsoft Excel is a spreadsheet developed by Microsoft for Microsoft Windows, Windows, macOS, Android (operating system), Android and iOS. It features calculation or computation capabilities, graphing tools, pivot tables, and a macro (comp ...
the floor function is implemented as INT (which rounds down rather than toward zero). The command FLOOR in earlier versions would round toward zero, effectively the opposite of what "int" and "floor" do in other languages. Since 2010 FLOOR has been fixed to round down, with extra arguments that can reproduce previous behavior. The
OpenDocument The Open Document Format for Office Applications (ODF), also known as OpenDocument, is an open file format for word processing documents, spreadsheets, presentations and graphics and using ZIP-compressed XML files. It was developed wi ...
file format, as used by
OpenOffice.org OpenOffice.org (OOo), commonly known as OpenOffice, is a discontinued open-source office suite. Active successor projects include LibreOffice (the most actively developed), Apache OpenOffice, Collabora Online (enterprise ready LibreOffice) a ...
,
Libreoffice LibreOffice () is a free and open-source productivity software, office productivity software suite, a project of The Document Foundation (TDF). It was fork (software development), forked in 2010 from OpenOffice.org, an open-sourced version of t ...
and others, uses the same function names; INT does floor and FLOOR has a third argument that can make it round toward zero.


See also

*
Bracket (mathematics) In mathematics, brackets of various typographical forms, such as parentheses ( ), square brackets nbsp; braces and angle brackets ⟨ ⟩, are frequently used in mathematical notation. Generally, such bracketing denotes some form of gro ...
*
Integer-valued function In mathematics, an integer-valued function is a function whose values are integers. In other words, it is a function that assigns an integer to each member of its domain. Floor and ceiling functions are examples of an integer-valued function o ...
*
Step function In mathematics, a function on the real numbers is called a step function if it can be written as a finite linear combination of indicator functions of intervals. Informally speaking, a step function is a piecewise constant function having only ...
*
Modulo operation In computing, the modulo operation returns the remainder or signed remainder of a division, after one number is divided by another (called the '' modulus'' of the operation). Given two positive numbers and , modulo (often abbreviated as ) is th ...


Notes


Citations


References

* * * * *Nicholas J. Higham, ''Handbook of writing for the mathematical sciences'', SIAM. , p. 25 *
ISO ISO is the most common abbreviation for the International Organization for Standardization. ISO or Iso may also refer to: Business and finance * Iso (supermarket), a chain of Danish supermarkets incorporated into the SuperBest chain in 2007 * Iso ...
/
IEC The International Electrotechnical Commission (IEC; in French: ''Commission électrotechnique internationale'') is an international standards organization that prepares and publishes international standards for all electrical, electronic and r ...
. ''ISO/IEC 9899::1999(E): Programming languages — C'' (2nd ed), 1999; Section 6.3.1.4, p. 43. * * * * *Michael Sullivan. ''Precalculus'', 8th edition, p. 86 *


External links

* * Štefan Porubský
"Integer rounding functions"
''Interactive Information Portal for Algorithmic Mathematics'', Institute of Computer Science of the Czech Academy of Sciences, Prague, Czech Republic, retrieved 24 October 2008 * * {{DEFAULTSORT:Floor And Ceiling Functions Special functions Mathematical notation Unary operations