Skip to content
Back to formatted view

Raw Message

Message-ID: <20080303184954.GA6337@psych.upenn.edu>
Date: 2008-03-03T18:49:54Z
From: Marianne Promberger
Subject: help for the first poster- a simple question
In-Reply-To: <001801c87d57$6193c4c0$3f4c1098@DNA271>

On 03/03/08 12:52, Xuejun Qin wrote:
> Hi, there, 
> I cannot  get accurate value  for calculation.
> for example:
> ld<-sqrt(1*0.05*0.95*0.05*0.95)
> 0.05*0.95-ld=-6.938894e-18
> 0.05*0.95-ld==0 is False.
> 
> I met this problem in my program, how can I handle it. Thanks.


I think what you are experiencing is this:
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

(R FAQ "7.31 Why doesn't R think these numbers are equal?")

Maybe handle it using round(). 

HTH

m.