From teck.lim at imperial.ac.uk  Mon May 29 18:22:20 2006
From: teck.lim at imperial.ac.uk (teck.lim at imperial.ac.uk)
Date: Mon, 29 May 2006 18:22:20 +0200 (CEST)
Subject: [Rd] Numerical error in R (win32) (PR#8909)
Message-ID: <20060529162220.E2ADE3F045@slim.kubism.ku.dk>

Hi
    I had observed the following problem in R (also C, Matlab, and Python).
sprintf('%1.2g\n', 3.15)
give 3.1 instead of 3.2 whereas an input of 3.75 gives 3.8.
Java's System.out.printf is ok though.  
 
> round(3.75,1)
[1] 3.8
> round(3.15,1)
[1] 3.1
 
Similar outcome with sprintf in R.


However, the right answer should be 3.2
 
Regards
Teckpor
 

	[[alternative HTML version deleted]]



[Rd] Numerical error in R (win32) (PR#8909)
teck.lim at imperial.ac.uk