[R] (1-1e-100)==1 true?

whf1984911 whf1984911 at yahoo.com.cn
Mon Jun 18 23:26:41 CEST 2012


Hi, 

This problems has bothered me for the lase couple of hours.  

> 1e-100==0
[1] FALSE
> (1-1e-100)==1
[1] TRUE

How can I tell R that 1-1e-100 does not equal to 1,  actually, I found out
that
 > (1-1e-16)==1
[1] FALSE
> (1-1e-17)==1
[1] TRUE

The reason I care about this is that I was try to use qnorm() in my code,
for example,

> qnorm(1e-100)
[1] -21.27345

and if I want to find qnorm(x) where x is very close to 1, say x=1-1e-100, 
then you would think using
qnorm(1-x, lower.tail=F) would give me something other than INF, but that
does not work since R would recognize x==1 in this case and therefore,
1-x==0, so qnorm(1-x, lower.tail=F) will give me INF which is what I try to
avoid in my code.

How could get around this, any suggestions?

Thanks,
Haifeng Wu
Graduate Student
University of South Carolina




--
View this message in context: http://r.789695.n4.nabble.com/1-1e-100-1-true-tp4633754.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list