[R] Rounding?

BXC (Bendix Carstensen) bxc at steno.dk
Mon Jun 11 13:18:01 CEST 2007


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 at steno.dk   http://www.biostat.ku.dk/~bxc

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



More information about the R-help mailing list