[英]Get ceiling of sqrt without float point. Python 3.7.3
I need to get the ceiling of a square root, such as 10**10001
(10^10001).我需要得到平方根的上限,例如10**10001
(10^10001)。 If I do:如果我做:
from math import sqrt
print(int(sqrt(10**10001))+1)
I look, and it gives me an OverflowError
.我看了一下,它给了我一个OverflowError
。 More precisely, a更准确地说,一个
Traceback (most recent call last)
File <stdin>, line 1, in <module>
OverflowError: int too large to convert to float.
I need a integer for an answer.我需要一个整数作为答案。 The OverflowError
is coming from the math.sqrt(x)
function. OverflowError
来自math.sqrt(x)
函数。 If anybody can help, it would be appreciated.如果有人可以提供帮助,将不胜感激。
the math module has a ceil and floor function数学模块具有 ceil 和 floor 功能
try print(math.ceil(math.sqrt(NUMBER)))尝试打印(math.ceil(math.sqrt(NUMBER)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.