[R] Rounding?

From: BXC (Bendix Carstensen) <bxc_at_steno.dk>
Date: Mon, 11 Jun 2007 13:18:01 +0200


I was a bit puzzed by:

> formatC(6.65,format="f",digits=1)

[1] "6.6"

So I experimented and found:

> formatC(6.6500000000000001,format="f",digits=1)
[1] "6.6"
> formatC(6.650000000000001,format="f",digits=1)
[1] "6.7"
> round(6.6500000000000001,1)

[1] 6.7
> round(6.650000000000001,1)

[1] 6.7
> version

               _                           
platform       i386-pc-mingw32             
arch           i386                        
os             mingw32                     
system         i386, mingw32               
status                                     
major          2                           
minor          5.0                         
year           2007                        
month          04                          
day            23                          
svn rev        41293                       
language       R                           
version.string R version 2.5.0 (2007-04-23)

My machine runs Windows NT.

Is this intended or just a Windows facility?


Bendix Carstensen
Senior Statistician

Steno Diabetes Center
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark

+45 44 43 87 38 (direct)
+45 30 75 87 38 (mobile)
+45 44 43 73 13 (fax)

bxc@steno.dk http://www.biostat.ku.dk/~bxc

This e-mail (including any attachments) is intended for the ...{{dropped}}



R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 11 Jun 2007 - 11:23:09 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 11 Jun 2007 - 12:31:37 GMT.

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