Nearest integer function

From Wikipedia, the free encyclopedia

In mathematics, the nearest integer function of a real number x is also called the nint or the round function. It is defined such that [x] is the integer closest to x. The square bracket notation [ ] is often used although this can also be used to denote the floor function.

To avoid ambiguity for half-integers, half-integers are always rounded to even numbers. For example, [1.5]==2, [2.5]==2, [3.5]==4, [4.5]==4, etc.

A more general discussion is given in the article on rounding, especially the Round-to-even section.