On Mar 4, 2010, at 4:50 AM, Petr PIKAL wrote: > Hi > > r-help-boun...@r-project.org napsal dne 04.03.2010 10:36:43: > >> >> Hi R Gurus, >> >> I am trying to figure out what is going on here. >> >>> a <- 68.08 >>> b <- a-1.55 >>> a-b >> [1] 1.55 >>> a-b == 1.55 >> [1] FALSE >>> round(a-b,2) == 1.55 >> [1] TRUE >>> round(a-b,15) == 1.55 >> [1] FALSE >> >> Why should (a - b) == 1.55 fail when in fact b has been defined to be a > - 1. >> 55? Is this a precision issue? How do i correct this? > > In real world those definitions of b are the same but not in computer > world. See FAQ 7.31 > > Use either rounding or all.equal. > >> all.equal(a-b, 1.55) > [1] TRUE > > To all, this is quite common question and it is documented in FAQs. > However there is no such issue in Excel or some other spreadsheet > programs, therefore maybe a confusion from novices. >
<snip> Actually, there are floating point issues in Excel. Search the archives using "Excel rounding" and you will see discussions dating back to circa 2003 on this, which also reference the differences in OO.org's Calc and Gnumeric's handling of floats. Also: http://support.microsoft.com/default.aspx?scid=kb;[LN];214118 http://support.microsoft.com/default.aspx?scid=kb;EN-US;78113 HTH, Marc Schwartz ______________________________________________ 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.