溢出错误:long int 太大无法转换为浮点数 [英] OverflowError: long int too large to convert to float

查看:52
本文介绍了溢出错误:long int 太大无法转换为浮点数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图得到一个非常大的数字的平方根,但我得到了错误:deltaSqrt = pow(delta,0.5)溢出错误:long int 太大而无法转换为浮点

I am trying to get the square root of a really large number yet I get the error: deltaSqrt = pow(delta,0.5) OverflowError: long int too large to convert to float

在我的情况下,delta 等于:

In my case delta is equal to:

509752415912430571120834697697209399451791855931983919398681840231635980912719828796195714368058047566515853712321166923850714510961491518350109099125837234891156709619839170054585928465187124316754832104764567313169044573638573145522635315514358552296032662507032712261065496253005633041839138612485457709020648038578927541671463102515536​​9128530489779489101162403615113670950177532664946764525175541382065187304866582420329863524912760301704277886453413147449455323732476653550495366827445013669840800229684474814585992820804300231060966713580804079322252173910482245551821723868004571663524727449944378683955667216

5097524159124305711208346976972093994517918559319839193986818402316359809127198287961957143680580475665158537123211669238507145109614915183501090991258372348911567096198391700545859284651871243167548321047645673131690445736385731455226353155143585522960326625070327122610654962530056330418391386124854577090206480385789275416714631025155369128530489779489101162403615113670950177532664946764525175541382065187304866582420329863524912760301704277886453413147449455323732476653550495366827445013669840800229684474814585992820804300231060966713580804079322252173910482245551821723868004571663524727449944378683955667216

我该怎么做才能得到这个数的平方根?

What should I do to get the square root of this number?

推荐答案

使用十进制:>

import decimal
>>> d = decimal.Decimal('5097524159124305711208346976972093994517918559319839193986818402316359809127198287961957143680580475665158537123211669238507145109614915183501090991258372348911567096198391700545859284651871243167548321047645673131690445736385731455226353155143585522960326625070327122610654962530056330418391386124854577090206480385789275416714631025155369128530489779489101162403615113670950177532664946764525175541382065187304866582420329863524912760301704277886453413147449455323732476653550495366827445013669840800229684474814585992820804300231060966713580804079322252173910482245551821723868004571663524727449944378683955667216')
>>> d.sqrt()
Decimal('7.139694782779097001143800270E+307')

这篇关于溢出错误:long int 太大无法转换为浮点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆