I'm working on a project and I noticed some strange values. I did some tests with various input values and ended up with this - what seems to me - weird behavior:
1 + 0.72 = 1.72 // expecting 1.72
2 + 0.72 = 2.7199999999999998 // 2.72
1 + 1.72 = 2.7199999999999998 // 2.72
1 + 2.72 = 3.72 // 3.72
1 + 3.72 = 4.720000000000001 // 4.72
Does anyone have a clue on what's going on and how to prevent this, that is, how do I make sure I get what I'm expecting?