Stack Exchange
Stack Overflow
Questions
Tags
Users
About
Stack Overflow
Public
Questions
Tags
Users
About
round function returns inconsistent results
Asked
Sep 09 '17 at 12:26
Active
Sep 09 '17 at 12:57
Viewed
57 times
0
Why
round(4.5)
is
4
and
round(3.5)
is also
4
?
Can anybody explain?
r
edited Sep 09 '17 at 12:57
pogibas
27,303
19
84
117
asked Sep 09 '17 at 12:26
vipul
1
Probably http://www.xbeat.net/vbspeed/i_BankersRounding.htm
–
Martin Smith
Sep 09 '17 at 12:27
2
Use `?round`, which will show "... Note that for rounding off a 5, the IEC 60559 standard is expected to be used, ‘go to the even digit’. Therefore round(0.5) is 0 and round(-1.5) is -2. ...".
–
67342343
Sep 09 '17 at 12:29
see also https://stackoverflow.com/q/39892999/3871924
–
agenis
Sep 09 '17 at 12:34
Thanks "67342343".. Got the answer
–
vipul
Sep 09 '17 at 12:41
With `cbind((x <- c(1,3,5,7,9,11,13,15,17,19)/200000), round(x, 5))` I also get the effects of numerical imprecession
–
Henry
Sep 09 '17 at 13:11
0 Answers
0