Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.A41.4.44.0308032008060.78202-100000@homer36.u.washington.edu>
Date: 2003-08-04T05:15:48Z
From: Thomas Lumley
Subject: round to even digit (PR#3604)
In-Reply-To: <200307311753.h6VHrpJH009691@pubhealth.ku.dk>

On Thu, 31 Jul 2003 kbroman@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@u.washington.edu	University of Washington, Seattle