[R] Number of decimal places

Rui Barradas ruipbarradas at sapo.pt
Sat Oct 27 00:44:27 CEST 2012


Hello,

There might be another problem with some of the numbers in the example. 
R uses C's double numeric type and that means that the limit is around 
16 decimal digits of precision. One of the numbers has 23, so there will 
allways be loss of accuracy.


a <- 111111111111234235423.56
b <- 11111111111.898

print(a, digits = 23)  # only 16 digits are accurate (up to the second 2)
print(b, digits = 16)

  The number 'a' is too long for R.

Hope this helps,

Rui Barradas
Em 26-10-2012 17:02, David Winsemius escreveu:
> Putting back the context:
>
> ( We are not looking at this with Nabble.)
>
>> When estimating values ​​each determined similarly, and in which get to them
>> by algebraic operations in some cases, are rounded with 0 decimal places and
>> in other cases with 2 or 3 decimal places. What is happening?
>> Thank you.
> On Oct 26, 2012, at 7:13 AM, DMMS wrote:
>
>> For example
>>
>>> a=12344.567
>>> a
>> [1] 12344.57
>>> b=234.567
>>> b
>> [1] 234.567
>>> a=111111111111234235423.56
>>> a
>> [1] 1.111111e+20
>>> b=11111111111.898
>>> b
>> [1] 11111111112
> ?options
>
> Pay attention to digits and scipen arguments
>
> Also look at:
>
>   ?format
>> --
> David Winsemius, MD
> Alameda, CA, USA
>
> ______________________________________________
> R-help at r-project.org 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.




More information about the R-help mailing list