我試圖得到一個長整型Python的math.sqrt損精
from math import sqrt
print sqrt(410241186411534352)
<< 640500731.0
開方值它返回640500731.0,這的確是640500730.999999993 ...精度。如何解決這個問題?
我根據@DSM和@ Rob的回覆解決了這個問題,非常感謝。
from math import sqrt
from decimal import Decimal
print Decimal(410241186411534352).sqrt()
如果你需要一個整數平方根函數,見[這個問題](http://stackoverflow.com/questions/15390807/integer-square-root-in-python)的幾個選項。 – DSM