0
我想找出一個數字的平方根。但數字很大。 Python中給出了錯誤如何在Python中查找大數的平方根?
OverflowError: int too large to convert to float
我的代碼是在這裏:
number=pow(255,200)-10000000
sqrt=math.sqrt(number)
我嘗試了與小數類,但它不工作。 如何在python中處理這些大數字?
我想找出一個數字的平方根。但數字很大。 Python中給出了錯誤如何在Python中查找大數的平方根?
OverflowError: int too large to convert to float
我的代碼是在這裏:
number=pow(255,200)-10000000
sqrt=math.sqrt(number)
我嘗試了與小數類,但它不工作。 如何在python中處理這些大數字?
import math
pow(10, 1/2 * math.log10(pow(255,200)-10000000))
結果是:4.508354347658245e + 240
它工作正常,但不能分配給變量。 – Praveen
十進制類它可以與它的'.sqrt'方法處理:'(POW(十進制(255),200)-10000000).sqrt( )'='十進制('4.508354347658170012443202806E + 240')' – Copperfield