R-alpha: round(.) : difference between R & S -- I'd prefer R's version, but...

Martin Maechler (maechler@stat.math.ethz.ch)
Mon, 10 Mar 97 17:55:52 +0100


Date: Mon, 10 Mar 97 17:55:52 +0100
Message-Id: <9703101655.AA00565@>
From: Martin Maechler <maechler@stat.math.ethz.ch>
To: R-testers mailing list <R-testers@stat.math.ethz.ch>
Subject: R-alpha: round(.) : difference between R & S -- I'd prefer R's version, but...

R> round(.5 + -3:7)
 [1] -3 -2 -1  1  2  3  4  5  6  7  8
S> round(.5 + -3:7)
 [1] -2 -2  0  0  2  2  4  4  6  6  8

So S  only returns even numbers for this case.
It behaves as documented:

S-?round>>   When rounding off a 5, the two common conventions are  to:
S-?round>>   1)  go  to  the higher number, or 2) go to the even digit.
S-?round>>   The round function obeys convention 2, so round(2.5) is  2
S-?round>>   and  round(3.5) is 4. The rounding mechanism for signif is
S-?round>>   machine dependent, but most machines will use  the  "round
S-?round>>   to even" rule.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- For info or help, send "info" or "help",
To [un]subscribe, send "[un]subscribe"
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-