0

I am tearing my hair out trying to figure this one. Lets say I have the following numeric vector:

mynumbers <- c(-3.6, -3.6, -2.6 , 4.4 , 5.4) 

Why does the sum(mynumbers) return -1.136868e-13 and not 0? Unless I am misunderstanding the sum function in R, shouldn't the numbers add up to 0?

JDiaz
  • 147
  • 1
  • 8
  • It does. See for example [Why doesn’t R think these numbers are equal?](https://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f). –  Aug 24 '15 at 08:10
  • 1
    Although this is a dupe, this does not deserves downvotes as no average R user should know these type of things. After all, we are just mathematicians who can't program... – David Arenburg Aug 24 '15 at 08:20
  • 1
    @DavidArenburg Neither a downvoter nor a mathematician. –  Aug 24 '15 at 08:23
  • @Pascal me too. It's just another name for a statistician. Old joke, nvm. – David Arenburg Aug 24 '15 at 08:25
  • 1
    @DavidArenburg Even not statistician :) Anyway, I agree with your comment. –  Aug 24 '15 at 08:26

0 Answers0