Skip to content
Prev 170062 / 398506 Next

How to handle large numbers?

On Wed, 11 Feb 2009, Feng Li wrote:

            
No.  0*Inf is NaN according to the floating point arithmetic standards that R depends on.

  It's true that 0*x==0 for all finite x, but it's also true that x*Inf==Inf for all non-zero x, and you can't preserve both of these with 0*Inf.
No. It should be close to 1. Try  1000/(1000+5) for a simpler example.
exp(1000)/(exp(1007)+5) is 1/(exp(7)+5*exp(-1000)), which is the same as 1/exp(7) to more than 400 digits accuracy.

            -thomas

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle