Reputation: 3898
I am trying to check if a large number is a perfect square. Here is the corresponding part of my code:
x = long(raw_input())
a = sqrt(5 * x ** 2 + 4)
b = sqrt(5 * x **2 - 4)
if long(a) == a or long(b) == b:
print "YES"
else:
print "NO"
However, when x becomes too large, I get this error:
a = sqrt(5 * x ** 2 + 4)
OverflowError: long int too large to convert to float
Can anybody tell me a workaround for this?
Upvotes: 2
Views: 5632