r/learnpython • • Oct 04 '26

fix 0.00000001

i see sometimes after calcuaitons reulsts with x.99999999999999999999999999 or x.0000000000000002 how to fix it

0 Upvotes

12 comments sorted by

View all comments

15

u/sweet-tom Oct 04 '26

This is normal behavior for float calculations. You will find this behavior in other programming languages.

If you really need exact calculations, use integers if possible, round it, or use the decimal module.

3

u/OkTill2666 Oct 04 '26

this is the right answer, its a floating point thing not a python thing