Here's a tip for the original poster.
> ?numeric
and then follow the link it suggests
> ?double
which says amongst other things
All R platforms are required to work with values conforming to the
IEC 60559 (also known as IEEE 754) standard. This basically works
with a precision of 53
> R by default uses floating-point arithmetic, which
> is subject to problems described in [*].
Yes.
I want to note that both graphics and modern statistics, require
efficient floating point arithmetic.
So, R does what it's designed to do...
__
R-help@
Your numbers are 70 bits long, R double precision numbers are 53 bits long.
You need Rmpfr to get the higher precision.
> log(569936821221962380720, 2)
[1] 68.94936
> print(569936821221962380720, digits=22)
[1] 569936821221962350592
> library(Rmpfr)
> mpfr("569936821221962380720", 70)
1 'mpfr' nu
On Wed, 18 Sep 2019 00:02:47 +0200
Martin Møller Skarbiniks Pedersen wrote:
> I know I can use gmp and R will do it correctly.
Which is equivalent to what Python does: it uses so-called long
arithmetic, allowing scalar variables with as many digits as it fits in
the computer memory. R by default
On 17/09/2019 6:02 p.m., Martin Møller Skarbiniks Pedersen wrote:
Hi,
I don't understand why R computes this wrong.
This is pretty well documented. R uses double precision floating point
values for these expressions, which have about 15 digit precision. I
believe for whole numbers Python
Hi,
I don't understand why R computes this wrong. I know I can use gmp and
R will do it correctly.
$ echo '569936821221962380720^3 + (-569936821113563493509)^3 +
(-472715493453327032)^3' | Rscript - [1] -4.373553e+46
Correct answer is 3 and Python can do it:
$ echo
'pow(569936821221962380720,3)
6 matches
Mail list logo