Nearest integer function
From Infogalactic: the planetary knowledge core
File:Nearest integer.svg
A plot of the nearest integer function, rounding to the nearest even integer
In computer science, the nearest integer function of real number x denoted variously by ,[1]
,
,[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,
- 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
References
- ↑ Weisstein, Eric W., "Nearest Integer Function", MathWorld.
- ↑ Lua error in package.lua at line 80: module 'strict' not found.