From dmurdoch at pair.com  Sat May 22 11:49:21 2004
From: dmurdoch at pair.com (dmurdoch@pair.com)
Date: Sat May 22 11:49:23 2004
Subject: [Rd] Inaccurate and Inconsistent results from 'round' function
	(PR#6905)
Message-ID: <20040522094921.A98721058C@slim.kubism.ku.dk>

On Sat, 22 May 2004 06:34:14 +0200 (CEST), jkbreaux@san.rr.com wrote:

>Full_Name: Jim Breaux
>Version: 1.9.0
>OS: WinXP
>Submission from: (NULL) (209.78.110.135)
>
>
>According to the help for 'round' it is supposed to round to the even digit. 
>However, see the following examples:

This is not a bug.  The problem is that floating point types do not
represent all decimal values exactly, so when you say

 > round(40.3655, 3)
 [1] 40.365

you are actually rounding a number which is slightly smaller than
40.3655.  The rounding works as advertised on exactly representable
numbers:

 > round(0.25,1)
 [1] 0.2
 > round(0.75,1)
 [1] 0.8

Duncan Murdoch


[Rd] Inaccurate and Inconsistent results from 'round' function (PR#6905)
dmurdoch@pair.com