[Rd] simple add error (PR#13699)
bolker at ufl.edu
Thu May 14 00:20:33 CEST 2009
> Full_Name: Gostan Thierry
> Version: 2.6.1 (2007-11-26)
> OS: Windows XP
> Submission from: (NULL) (220.127.116.11)
> I cannot explain why R seems to have problems adding two big numbers.
> sprintf("%f",10^4+10^19) gives "10000000000000010240.000000"
> instead of "10000000000000010000.000000"
> problems seems to arrive when i'm trying to add a big and a small
I can't give you the exact answer here -- someone else may chime in with
more details -- but the basic problem is that you are reaching the limits of
double precision arithmetic -- see ?.Machine , which gives
double.eps: the smallest positive floating-point number 'x' such that
'1 + x != 1'. It equals 'base^ulp.digits' if either 'base'
is 2 or 'rounding' is 0; otherwise, it is '(base^ulp.digits)
/ 2'. Normally '2.220446e-16'.
I can't say exactly why things get wonky at 10^4+10^18 (I would have
would be good for another order of magnitude), but that's just my
to think about numerical computation more carefully at the moment.
Check out various threads on the mailing lists about bc and yacas (although
I'm not sure if yacas runs on Windows or not).
View this message in context: http://www.nabble.com/simple-add-error-%28PR-13699%29-tp23530242p23531057.html
Sent from the R devel mailing list archive at Nabble.com.
More information about the R-devel