Skip to content
Prev 20849 / 63424 Next

Numerical error in R (win32) (PR#8909)

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.
[1] 3.8
[1] 3.1
 
Similar outcome with sprintf in R.


However, the right answer should be 3.2
 
Regards
Teckpor