On Fri, 2008-11-07 at 15:53 +0530, Shubha Vishwanath Karanth wrote:
> 
> Hi R,
> 
>  
> 
> I have certain checkings, which gives FALSE, but actually it is true. Why 
> does this happen? Note that the equations that I am checking below are not 
> even the case of recurring decimals...
> 
>  
> 
> > 1.4^2 == 1.96
> 
> [1] FALSE
> 
>  
> 
> > 1.2^3==1.728
> 
> [1] FALSE


Shubha

the correct answer for us is TRUE for the computer is FALSE

1.4^2-1.96
[1] -2.220446e-16

1.2^3-1.728
[1] -2.220446e-16

but if you use "all.equal" 

all.equal(1.4^2,1.96)
[1] TRUE

all.equal(1.2^3,1.728)
[1] TRUE


More details in R FAQ 7.31





-- 
[]s
Tura

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to