[Rd] round(#, digits=x) unreliable for x=2 (PR#9682)

From: <scott.wilkinson_at_csiro.au>
Date: Mon, 14 May 2007 02:46:45 +0200 (CEST)

Full_Name: Scott Wilkinson
Version: 2.3.1
OS: WinXP Pro
Submission from: (NULL) (

In the example below round() does not report to the specified number of digits when the last digit to be reported is zero: Compare behaviour for 0.897575 and 0.946251. Ditto for signif(). The number of sigfigs is ambiguous unless the reader knows this behaviour. Is this a bug or intended behaviour? Is there a work-around?

#Example code:

number <- 0.897575 # this one isn't reported to 2 decimal places 0.90 as expected
#number <- 0.946251 # when the last reported digit is non-zero it gives expected

Round3 <- round(number, digits=3)
Round2 <- round(number, digits=2)       #why 0.9 and not 0.90 for 0.897575?
Round1 <- round(number, digits=1)

Signif3 <- signif(number, digits=3)

Signif2 <- signif(number, digits=2) #why 0.9 and not 0.90 0.897575? Signif1 <- signif(number, digits=1)

Results <- data.frame(Round3, Round2, Round1, Signif3, Signif2, Signif1)

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 14 May 2007 - 09:36:33 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 May 2007 - 11:33:57 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.