Skip to content
Prev 77743 / 398502 Next

as.character on OS X tiger

This is just a question of rounding error.  You are computing 11/999, 
which is not exactly representable.  Most computers use IEC60559 
arithmetic, which gives a precision of .Machine$double.eps ~ 2e-16.  So 
you can expect rounding error around 11/999 * .Machine$double.eps ~ 2e-18. 
However, as.character is documented to represent the number to 15 
significant digits.

On all of Linux (i686 and AMD64), Solaris and Windows boxes I get
[1] 0.01101101
[1] 1.040834e-17
[1] "0.0110110110110110"
[1] "0.011011011011011"

and these are different representations of different numbers.

So your claim to get different results on `linux' is not one I can 
reproduce.

The fix is not to rely on the fine details of numerical (or character) 
representations of numbers: perhaps convert them back to numbers and use 
all.equal()?
On Fri, 23 Sep 2005, Marcus Davy wrote: