wtfpython
wtfpython copied to clipboard
Minor snippet: Statistical rounding
Definitely not a Python-related wtf, but nice to know anyways
>>> round(1.25, 1)
1.2
>>> round(1.35, 1)
1.4
>>> round(1.45) + round(1.55) == 3
True
https://docs.python.org/3/tutorial/floatingpoint.html#tut-fp-issues
That's very intriguing. 😱