Re: [R] calculate differences - strange outcome

From: Berwin A Turlach <berwin_at_maths.uwa.edu.au>
Date: Thu, 17 Jul 2008 18:21:00 +0800

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


R-help_at_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. Received on Thu 17 Jul 2008 - 10:24:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Jul 2008 - 11:32:44 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive