0

When I calculate the mean of the following:

 mean(c(-2.1,-0.2,-1.1,-0.5,2.5,1.4))
[1] -0.00000000000000004627736

I get a result that is not 0 although it should be zero (you can calculate it yourself with a calculator)

Raju Ahmed
  • 1,282
  • 5
  • 15
  • 24
  • 4
    [Why are these numbers not equal?](https://stackoverflow.com/questions/9508518/why-are-these-numbers-not-equal/9508558#9508558) – user2974951 Jun 13 '22 at 11:55
  • Computers are not very good with floating point numbers and they do math differently than we humans do it. When working with decimal values, some small "errors" may appear. The value returned is close enough to 0 for most practical purposes. – MrFlick Jun 13 '22 at 12:51

0 Answers0