I'm looking for the fastest way to determine if a long
value is a perfect square (i.e. its square root is another integer). I've done it the easy way, by using the built-in Math.sqrt() function, but I'm wondering if there is a way to do it faster by restricting yourself to integer-only domain. Maintaining a lookup table is impratical (since there are about 2 31.5 integers whose square is less than 2 63 ).
Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Showing posts with label perfect-square. Show all posts
Showing posts with label perfect-square. Show all posts
Friday, May 25, 2012
Fastest way to determine if an integer"s square root is an integer
Subscribe to:
Posts (Atom)