Assign $t\leftarrow\frac{2\theta}\pi$, $s\leftarrow\sin\theta$, $c\leftarrow\cos\theta$
Test if $s^2+c^2=1$ (within desired precision).
Let $r= \lfloor t \rfloor$. If $r\equiv 0\pmod 4$, verify that $s\ge 0, c\ge 0$. If $r\equiv 1\pmod 4$, verify that $s\ge 0, c\le 0$. If $r\equiv 2\pmod 4$, verify that $s\le 0, c\le 0$. If $r\equiv 3\pmod 4$, verifiy that $s\le 0,c\le 0$.
Assign $t\leftarrow 2t$, $s\leftarrow 2sc$, $c\leftarrow 2c^2-1$ and go back to step 3
If any of the tests in 2 or 3 fails, the values are falsified. In principle, the loop in steps 3 and 4 may be executed infinitely often, but you should break out of it after just a few iterations (ten, say) when you are satisfied with the precision achieved.
The test in 3 checks if the values are in the correct quadrant and step 4 doubles the angle, thereby effectivekly refining the partition into quadrants into something finer.