开发者

how to compute division accurately in python?

I tried the following computation in python:

>>> 12.2 / 0.2
60.99999999999999

it's obviously that i开发者_如何学JAVAt didn't return the exact answer.

According to the answers in text, l have known that we can use decimal.Decimal to obtain accurate calculation。 But I'm confused that if I have to use decimal.Decimal every time in my project to obtain exact results, is there any other method to ensure obtaining exact results in practice?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜