Perfect square test (source code)

= Perfect square test

For a <nonnegative integer> $n$, compute its <integer square root> $r=\lfloor\sqrt n\rfloor$ and accept exactly when $r^2=n$. An approximate <square root> must be corrected with exact <integer> comparisons before this equality is tested. This procedure distinguishes a squareness test from merely approximating a <square root>.