On 4/8/2006 3:51 PM, Mike Leahy wrote:> Hello list,
>
> I'm just getting started with R, and I'm trying to determine how R
> treats large numbers that have decimals. Take the following two examples:
>
>> x <- c(999999999999999.9)
>> sprintf("%.5f",x)
> [1] "999999999999999.87000"
>
>> y <- c(9999999999999999.9)
>> sprintf("%.5f",y)
> [1] "10000000000000000.00000"
>
> I realize that I have no idea what I'm doing as far as using R is
> concerned, but maybe someone can tell me what would be the best way to
> input/output numbers such that they don't get rounded off in unexpected
> ways. I've been searching online and looking through various R
manuals,
> but I haven't found anything that really clarifies this so far...
R uses standard double precision storage for floating point numbers,
which means approximately 15-16 decimal place accuracy. There isn't
anything you can easily do to improve this in general, though the gmp
package allows some calculations to high precision.
Duncan Murdoch