Many programming languages and scientific computing systems follow the
"round half to even"
tie-breaking rule; this is also the default rounding mode in the IEEE
standard for floating-point
arithmetic (IEEE 754). So in R or Python (with NumPy), but not in, e.g.,
MATLAB) we have
round(0.5) #=> 0
round(1.5) #=> 2
round(2.5) #=> 2
round(3.5) #=> 4
...
but in Julia
julia> (round(0.5), round(1.5), round(2.5), round(3.5))
(1.0,2.0,3.0,4.0)
julia> (round(-0.5), round(-1.5), round(-2.5), round(-3.5))
(-1.0,-2.0,-3.0,-4.0)
Is there a special reason for Julia to follow instead the "round half away
from zero" rule, for
instance compatibility with MATLAB?