Marc Jekel <feuerwald <at> gmx.de> writes: > Another question for the community that really frightened me today. The > following logical comparison produces a "false" as output: > > t = sum((c(.7,.69,.68,.67,.66)-.5)*c(1,1,-1,-1,1)) > tt = sum((c(.7,.69,.68,.67,.66)-.5)*c(1,-1,1,1,-1)) > > t == tt > > This is really strange behavior. Most likely this has something to do > how R represents numbers internally and the possible sensitivity of a > computer? Does anyone know when this strange behavior occurs and how to > fix it? > > Thank you all! This list is pleasure!!! > > Marc >
But, try all.equal(tt, t) [1] TRUE and see the R FAQ 7.31 -- Ken Knoblauch Inserm U846 Stem-cell and Brain Research Institute Department of Integrative Neurosciences 18 avenue du Doyen Lépine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.sbri.fr/members/kenneth-knoblauch.html ______________________________________________ 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.