0

I would expect summing arrays to give the same number regardless of order. This test disagrees. What is causing this?

>>> sum([0.2, 1.0, 0.3939393939393939, 0.8846153846153846])
2.4785547785547783
>>> sum([0.8846153846153846, 1.0, 0.3939393939393939, 0.2])
2.478554778554779

This is making tests annoying to write as sometimes I am getting slightly different floats that cause assertions to fail.

tknickman
  • 4,285
  • 3
  • 34
  • 47

0 Answers0