Message-ID: <AD958B48-665A-43A7-BDA4-421F22B2B776@me.com>
Date: 2012-08-24T12:45:09Z
From: Marc Schwartz
Subject: R minimal calculation error
In-Reply-To: <CAPSkfAMdR5nO1P_D-7zYswv2poC8WbCyFU0tPygCgn8EoDNqbw@mail.gmail.com>
On Aug 24, 2012, at 5:48 AM, Frederik Bertling <Frederik.Bertling at stud.uni-due.de> 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.315223e-18
> This is really near to 0 but not very aesthetic.
>
> Can I prevent this? Or is this behaviour desired?
> Thank you very much!
> Burtan
Read this:
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f
Regards,
Marc Schwartz