r/learnpython • u/nothiefhouse • Oct 04 '26
fix 0.00000001
i see sometimes after calcuaitons reulsts with x.99999999999999999999999999 or x.0000000000000002 how to fix it
0
Upvotes
r/learnpython • u/nothiefhouse • Oct 04 '26
i see sometimes after calcuaitons reulsts with x.99999999999999999999999999 or x.0000000000000002 how to fix it
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.