[R] Simple addition and subtraction doesn't work??

2008-10-03 Thread Adrian Teo
I was working on a teaching example, but came across this weird result: > q<-c(1.6,2.6, -3.4) > q [1] 1.6 2.6 -3.4 > sum(q) [1] 0.8 > sum(q)- 0.8 [1] 2.22044605e-16 Why is the result not precisely zero? Thanks! AT __ R-help@r-project.org mailing li

Re: [R] Simple addition and subtraction doesn't work??

2008-10-03 Thread Erik Iverson
Depending on the class, you might have another teaching opportunity. See R FAQ 7.31 and the document it points to. Adrian Teo wrote: I was working on a teaching example, but came across this weird result: q<-c(1.6,2.6, -3.4) q [1] 1.6 2.6 -3.4 sum(q) [1] 0.8 sum(q)- 0.8 [1] 2.22044605e

Re: [R] Simple addition and subtraction doesn't work??

2008-10-04 Thread Uwe Ligges
Erik Iverson wrote: Depending on the class, you might have another teaching opportunity. right away after showing your students that (and why) x + 1 - x = 0 Example: x <- 10^20 x + 1 - x Uwe Ligges See R FAQ 7.31 and the document it points to. Adrian Teo wrote: I was working on