To check if a natural number is a perfect square, programming in Python, I check if int(math.sqrt(n))==math.sqrt(n), id est if the decimal part of the square root is zero.
Here my question: are there cases such that this test could fail due to approximation error?
Here what I get thinking by myself. The test above will fail if $n$ has a square root of the form $b_1 b_2...b_n,000...000a_1a_2...$ with enough zeros such that the decimal part is smaller than the minimum representable number.
By hypothesis $n=(b_1 b_2...b_n,000...000a_1a_2...)^2 = (b_1 b_2...b_n+0,000...000a_1a_2...)^2 =$ $= (b_1 b_2...b_n)^2+2(b_1 b_2...b_n \times 0,000...000a_1a_2...)+ (0,000...000a_1a_2...)^2$
It follows that there's a positive integer $m$ such that $m=2(b_1 b_2...b_n \times 0,000...000a_1a_2...)+ (0,000...000a_1a_2...)^2$.
It is not clear to me if a positive integer $n$ with such $a_1a_2...$ and $b_1...b_n$ could exist. Any idea?