Re: [R] R minimal calculation error

2012-08-24 Thread Petr Savicky
On Fri, Aug 24, 2012 at 12:48:54PM +0200, Frederik Bertling wrote: > Hi, > > I'm doing some easy calculations to normalize some values. This looks like > this: > > x=mean(a+b+c+d ...) > a=a-x > b=b-x > c=c-x > d=d-x > ... > mean(a+b+c+d ...) ---> Should now be 0! > However, I'm getting results li

Re: [R] R minimal calculation error

2012-08-24 Thread Rui Barradas
Hello, This is FAQ 7.31 Why doesn't R think these numbers are equal? As for your second question whether this behavior is desirable I think so, we should be aware that floating-point arithmetics has limits. In your case, a precision limit. At an R pompt run the instructions ?.Machine .Machin

Re: [R] R minimal calculation error

2012-08-24 Thread Marc Schwartz
On Aug 24, 2012, at 5:48 AM, Frederik Bertling wrote: > Hi, > > I'm doing some easy calculations to normalize some values. This looks like > this: > > x=mean(a+b+c+d ...) > a=a-x > b=b-x > c=c-x > d=d-x > ... > mean(a+b+c+d ...) ---> Should now be 0! > However, I'm getting results like -2.3152

[R] R minimal calculation error

2012-08-24 Thread Frederik Bertling
Hi, I'm doing some easy calculations to normalize some values. This looks like this: x=mean(a+b+c+d ...) a=a-x b=b-x c=c-x d=d-x ... mean(a+b+c+d ...) ---> Should now be 0! However, I'm getting results like -2.315223e-18 This is really near to 0 but not very aesthetic. Can I prevent this? Or is