The **nearest integer function** (also called *nint* or *x-rounded*) g(x) = {x} assigns the nearest integer to *x* for every real number. If x is in the middle of two integers, the function returns the largest of the two numbers (Gerstein, 2012), which avoids statistical bias (Nemati et al., 2013).

A few examples:

- {1.99} = 2,
- {6} = 6,
- {3.5} = 4,
- {-0.6} = -1,
- {-4.5} = -4.

The function is mostly used in number theory and approximation theory, with some application in dynamical system theory. It can also “tidy up a good many otherwise complicated formulas” such as the formula for the number of permutations of n letters with no fixed points:

Which, when you realize that the sum is a truncation of the infinite series for e^{-1}, simplifies to:

D_{n} = ||n!/e|| for n ≥ 1.

(Wilf, 1987, p. 855.).

Similar functions that belong to the same family — functions that return real integers based on a particular rule — include the ceiling (least integer) function and floor (greatest integer) function.

## Notation for the Nearest Integer Function

The nearest integer function doesn’t have a commonly accepted standard notation. While it’s common to use curly brackets to represent the nearest integer function (as in the examples above), the symbol || || is also used; For example, ||0.49|| = 0 (Brown, 1998). Other notation includes the symbol “(x)” (Singh, 2021) and

Occasionally, brackets [] are used, but these can be confused with equivalence class. In addition, the floor function is sometimes denoted with brackets, especially in older texts, compounding the potential confusion. The notation |_x] is also sometimes used (Hastad et al. 1988), but this notation is cumbersome and not recommended (Nemati et al, 2013).

## References

Brown, P. (1998). Advances in Chromatography – Volume 39 – Page 154. Taylor & Francis.

Gerstein, L. (2012). Introduction to Mathematical Structures and Proofs. Springer.

Hastad, J.; Just, B.; Lagarias, J. C.; and Schnorr, C. P. “Polynomial Time Algorithms for Finding Integer Relations among Real Numbers.” SIAM J. Comput. 18, 859-881, 1988.

Nemati et al., (2013). Using Black Holes Algorithm in Discrete Space by Nearest

Integer Function. IAES International Journal of Artificial Intelligence (IJ-AI)

Vol. 2, No. 4, December 2013, pp. 173~178.

Singh, S. (2021). 3.9 Greatest and least integer functions. Retrieved January 27, 2021 from: https://cnx.org/contents/[email protected]:[email protected]/Greatest-and-least-integer-functions

Wilf, H. (1987). The Editor’s Corner: Strings, Substrings, and the `Nearest Integer’ Function. The American Mathematical Monthly Vol. 94, No. 9 (Nov., 1987), pp. 855-860 (6 pages) Published By: Taylor & Francis, Ltd.

**CITE THIS AS:**

**Stephanie Glen**. "Nearest Integer Function" From

**CalculusHowTo.com**: Calculus for the rest of us! https://www.calculushowto.com/nearest-integer-function/

**Need help with a homework or test question? **With Chegg Study, you can get step-by-step solutions to your questions from an expert in the field. Your first 30 minutes with a Chegg tutor is free!