Re: [R] Rounding?

From: Peter Dalgaard <P.Dalgaard_at_biostat.ku.dk>
Date: Mon, 11 Jun 2007 16:56:52 +0200

jim holtman wrote:
> your number 6.6500000000000001 is to large to fit in a floating point
> number. It takes 56 bits and there are only 54 in a real number so the
> system see it as 6.65 and does the rounding to an even digit; 6.6
>
> 6.650000000000001 does fit into a real number (takes 54 bits) and this will
> now round to 6.7
>
>
Actually, a bit more insidious than that because 6.65 does not have an exact binary representation. Hence

> round(66.5)

[1] 66
> round(6.65,1)

[1] 6.7
> round(0.665,2)

[1] 0.66

Notice that these are from Linux and differ from what you get on Windows.

-- 
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard_at_biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
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 - 15:21:01 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 - 16:31:48 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.