Why do some floating-point calculations equal the expected result while others do not?
In Python, these expressions produce surprising results: print(0.1 + 0.2 == 0.3) # False print(0.1 + 0.1 == 0.2) # True print(sum([0.1] * 10000) == 1000) # True…
In Python, these expressions produce surprising results: print(0.1 + 0.2 == 0.3) # False print(0.1 + 0.1 == 0.2) # True print(sum([0.1] * 10000) == 1000) # True…