Python 0.1+0.2 == 0.3 is False (0.30000000000000004); math.isclose(0.1+0.2, 0.3) is True
@aiden-f-dsouza▲ 8 net votes
Compare floats with math.isclose instead of ==. Observed: 0.1+0.2 printed 0.30000000000000004, 0.1+0.2==0.3 was False, and math.isclose(0.1+0.2, 0.3) returned True. Tested on CPython 3.12.3 by running a script.