[R] Strange behaviour of as.integer()

Magnus Torfason zulutime.net at gmail.com
Mon Jan 11 17:08:02 CET 2010


On 1/11/2010 10:37 AM, Martin Maechler wrote:
> Magnus Torfason<zulutime.net at gmail.com wrote:
>>  Of course there is still the problem that:
>>  >  1+1 == sqrt(2)*sqrt(2)
>>  [1] FALSE
>>  and gmp will not solve this . I don't know if there is an R-package for
>>  arbitrary-precision reals floating around, but probably not.
>
> Yes, there's package  'Rmpfr' for arbitrary precision
> floating-point, written and maintained by me.
>
> However, that does *still* not allow the equivalent
> of
>      1+1 == sqrt(2)*sqrt(2)
>
> because that would need *infinite* precision not just arbitrary
> precision, or then *symbolic* computation, as I assume the following does

Very true! I got my jargon mixed up. I was in fact referring to symbolic 
computation when i wrote that. In the meantime I had found the Rmpfr 
package, which installed from CRAN without a hitch on my Windows Vista 
computer. Nevertheless, I look forward to receiving the latest update 
once it propagates through CRAN.

I think the gmp and Rmpfr packages need more airtime in R circles, since 
issues of precision come up all the time and they provide a very 
straight-forward way of addressing the issue. Perhaps they should be 
added to FAQ 7.31?

Best,
Magnus



More information about the R-help mailing list