[Rd] round to even digit (PR#3604)
Thomas Lumley
tlumley at u.washington.edu
Sun Aug 3 21:15:43 MEST 2003
On Thu, 31 Jul 2003 kbroman at jhsph.edu wrote:
> Full_Name: Karl W Broman
> Version: 1.7.1
> OS: Linux
> Submission from: (NULL) (162.129.44.18)
>
>
> There appears to be a slight problem with round(); for rounding off a 5,
> it should go to the even digit, but there appear to be some cases where
> it goes to an odd digit; see below.
>
I think this may be a case where the number doesn't actually end in 5, it
just appears to
> round(217.5)
[1] 218
> round(21.75*10)
[1] 218
> round(2.175*100)
[1] 217
> round(0.2175*1000)
[1] 218
since .175 isn't exactly expressible in binary.
-thomas
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-devel
mailing list