Nearest integer function
Encyclopedia
In computer science
Computer science
Computer science or computing science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems...

, the nearest integer function of real number
Real number
In mathematics, a real number is a value that represents a quantity along a continuum, such as -5 , 4/3 , 8.6 , √2 and π...

 x denoted variously by , , , nint(x), or Round(x), is a function
Function (mathematics)
In mathematics, a function associates one quantity, the argument of the function, also known as the input, with another quantity, the value of the function, also known as the output. A function assigns exactly one output to each input. The argument and the value may be real numbers, but they can...

 which returns the nearest integer
Integer
The integers are formed by the natural numbers together with the negatives of the non-zero natural numbers .They are known as Positive and Negative Integers respectively...

 to x. To avoid ambiguity when operating on half-integer
Half-integer
In mathematics, a half-integer is a number of the formn + 1/2,where n is an integer. For example,are all half-integers. Note that a half of an integer is not always a half-integer: half of an even integer is an integer but not a half-integer...

s, a rounding
Rounding
Rounding a numerical value means replacing it by another value that is approximately equal but has a shorter, simpler, or more explicit representation; for example, replacing $23.4476 with $23.45, or the fraction 312/937 with 1/3, or the expression √2 with 1.414.Rounding is often done on purpose to...

 rule must be chosen. On most computer implementations, the selected rule is to round half-integers to the nearest even integer — for example,
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.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK