Let's say I'm considering M=N**2
where N
is an integer. It appears that numpy.sqrt(M)
returns a float (actually numpy.float64).
I could imagine that there could be a case where it returns, say, N-10**(-16)
due to numerical precision issues, in which case int(numpy.sqrt(M))
would be N-1
.
Nevertheless, my tests have N==numpy.sqrt(M)
returning True
, so it looks like this approximation isn't happening.
Is it safe for me to assume that int(numpy.sqrt(M))
is indeed accurate when M
is a perfect square? If so, for bonus, what's going on in the background that makes it work?