[R] calculate differences - strange outcome

Berwin A Turlach berwin at maths.uwa.edu.au
Thu Jul 17 12:21:00 CEST 2008


On Thu, 17 Jul 2008 11:47:42 +0200
"Kunzler, Andreas" <a.kunzler at bzaek.de> wrote:

> I ran into some trouble by calculating differences. For me it is
> important that differences are either 0 or not.

If that is the case, restrict yourself to calculating with integers. :)

> So I don't understand the outcome of this calculation
> 
> 865.56-(782.86+0+63.85+18.85+0)
> [1] -1.136868e-13
> 
> I run R version 2.71 on WinXP
> 
> I could solve my problem by using
> round()
> but I would like to know the reason.
> Maybe someone can help me?

FAQ 7.31 and the reference cited therein should shed light on your
problem.

Best wishes,

	Berwin

=========================== Full address =============================
Berwin A Turlach                            Tel.: +65 6516 4416 (secr)
Dept of Statistics and Applied Probability        +65 6516 6650 (self)
Faculty of Science                          FAX : +65 6872 3919       
National University of Singapore     
6 Science Drive 2, Blk S16, Level 7          e-mail: statba at nus.edu.sg
Singapore 117546                    http://www.stat.nus.edu.sg/~statba



More information about the R-help mailing list