The question asked: 17: If we have variables var1 = 0.1 var2 = 0.2 and we want to compare their sum with var3 = 0.3, which of the following is the correct way to do it?
- (var1 + var2) == var3
- round(var1,1) + round(var2, 1 ) == round(var3,1)
- round(var1+ var2, 10) == round(var3, 10)
The answer was 2 but when reading up about floating arithmetic I thought it was 3. Can anyone guide me through this?