Main Index Number Theory Arithmetic Functions
 Subject Index
comment on the page

Integer rounding functions

Integer part

Let typeset structure. The integer part function 1 is defined as the largest integer less or equal to typeset structure, formally it is defined as typeset structure. There are many notations used for this important function but none was generally adopted:   

This function can also appear also in another form, as the truncation function, where we discard the noninteger part of a positive real number. In general, the term truncation is used for reducing the number of digits right of the decimal point. Given a positive real number typeset structure to be truncated and typeset structure, the number of digits to be kept behind the decimal point, the truncated value is given by

⌊ 10^n · x ⌋/10^n .

For negative real numbers truncation rounds toward zero.

If typeset structure and typeset structure then

Ceiling function

When Iverson introduced his half-bracket notation for the integer part function, he also introduced very closely related ceiling function (previously often called upper integer part function)  

⌈ x ⌉ = min {m ∈ Z : m >= x} .

This function is also often named as the post-office function, because of the rounding the intermediate weights up to the next scale point for postal charges.

If typeset structure and typeset structure then

The fractional part

This is actually a companion function to the integer part function, and it is usually defined as the difference between typeset structure and typeset structure, that is typeset structure. The symbol typeset structure is used for this function, especially in number theory, even if the confusion with the set theoretic meaning of the same symbol is possible.

Clearly, typeset structure is a periodic function with period 1 has the following Fourier expansion

{x} = 1/2 - 1/π Underoverscript[∑, n = 1, arg3] (sin    2 π n x)/n ,     x ∉ Z .(1)

If typeset structure then we have typeset structure, but if typeset structure then this relation is not longer true.  To save the previous relation also for negative real numbers, the fractional part function is sometimes also defined by

frac(x) = {x - ⌊ x ⌋ ,    if x >= 0, and             x - ⌊ x ⌋ - 1, if x < 0.

Nearest integer function

The nearest integer function is formally defined as the closed integer to typeset structure. Since this definition is not unambiguous for half-integers, the additional rule is necessary to adopt,  for instance

Let us take for the definition the first possibility, that is the nearest integer function denoted by typeset structure is defined by  typeset structure. Then

Distance to the nearest integer

This function is defined by typeset structure. It is a periodic function with period 1 and Fourier expansion

(x) = 1/4 - 2/π^2 Underoverscript[∑, n = 0, arg3] (cos 2 π(n + 1) x)/(2 n + 1)^2 .(2)


1 Also called entier function or greatest integer function or floor function


[1]  Gauß, C. F. (1808, Jan.). Theorematis arithmetici demonstratio nova. Comment. Soc. regiae sci. Göttingen , XVI, 1-8 (Werke II, p. 1-8 ).

[2]  Legendre, A. M. (1808). Théorie des nombres (ed. 2).

[3]  Iverson, K. E. (1962). A Programming Language. New York: Wiley.

Cite this web-page as:

Štefan Porubský: Integer rounding functions.

Page created  .