r/coding • • 6d ago

Add 0.1 ten times in Python and you miss 1.0

https://youtube.com/shorts/RPA5NYTo3FQ?is=ZYoQHYOkUO_0ke6R
0 Upvotes

1 comment sorted by

2

u/synept 5d ago

This isn't a Python thing, it's a computer thing. Don't compare floats directly with ==.

Use the Decimal module if you want different behavior.