# .

# Nearest integer function

In computer science, the nearest integer function of real number x denoted variously by [x],[1] \( \lfloor x \rceil, \Vert x \Vert,[2] nint(x) \), or Round(x), is a function which returns the nearest integer to x. To avoid ambiguity when operating on half-integers, a rounding rule must be chosen. On most computer implementations, the selected rule is to round half-integers to the nearest even integerâ€”for example,

[1.25] = 1

[1.50] = 2

[1.75] = 2

[2.25] = 2

[2.50] = 2

[2.75] = 3

[3.25] = 3

[3.50] = 4

[3.75] = 4

[4.50] = 4

etc.

This is in accordance with the IEEE 754 standards and helps reduce bias in the result.

There are many other possible rules for tie breaking when rounding a half integer include rounding up, rounding down, rounding to or away from zero, or random rounding up or down.

See also

Floor and ceiling functions

References

Weisstein, Eric W., "Nearest Integer Function", MathWorld.

J.W.S. Cassels (1957). An introduction to Diophantine approximation. Cambridge Tracts in Mathematics and Mathematical Physics 45. Cambridge University Press. p. 1.

.

Undergraduate Texts in Mathematics

Graduate Studies in Mathematics

Retrieved from "http://en.wikipedia.org/"

All text is available under the terms of the GNU Free Documentation License