[R] calculate differences - strange outcome

Mark Difford mark_difford at yahoo.co.uk
Thu Jul 17 12:23:00 CEST 2008


Hi Andreas,

It's because you are dealing with binary or floating point calculations, not
just a few apples and oranges, or an abacus (which, by the way, is an
excellent calculating device, and still widely used in some [sophisticated]
parts of the world).

http://en.wikipedia.org/wiki/Floating_point

HTH, Marks.


Kunzler, Andreas wrote:
> 
> Dear List,
> 
> I ran into some trouble by calculating differences. For me it is
> important that differences are either 0 or not.
> 
> 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?
> 
> Thanx
> 
> ______________________________________________
> 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/calculate-differences---strange-outcome-tp18505010p18505498.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list