1

Is there any way to force the round function in R 3.6.1 to print the ceiling value, even when rounding off a 5. According to the function's documentation:

Note that for rounding off a 5, the IEC 60559 standard (see also ‘IEEE 754’) is expected to be used, ‘go to the even digit’. Therefore round(0.5) is 0 and round(-1.5) is -2.

Does anyone know why rounding the midpoint between an odd and (the next largest) even integer will return the floor, whereas the midpoint between an even and (the next largest) odd integer returns the ceiling?

sequence <- seq(1.5, 10.5, by = 1)

data.frame(data = sequence, 
           rounded = sapply(sequence, round), 
           floor = sapply(sequence, floor), 
           ceiling = sapply(sequence, ceiling))

   data rounded floor ceiling
1   1.5       2     1       2
2   2.5       2     2       3
3   3.5       4     3       4
4   4.5       4     4       5
5   5.5       6     5       6
6   6.5       6     6       7
7   7.5       8     7       8
8   8.5       8     8       9
9   9.5      10     9      10
10 10.5      10    10      11

My session info (sorry for the low resolution img):

enter image description here

Dij
  • 1,318
  • 1
  • 7
  • 13
  • 2
    Maybe take a look here: https://stackoverflow.com/questions/12688717/round-up-from-5 – DanY Apr 29 '20 at 19:21
  • thanks @DanY. I wish it were as simple as passing an arg to `round` to toggle the IEC standard – Dij Apr 29 '20 at 19:26

0 Answers0