Update: Unstruck on advice ;)
I also agree that it deserved being unstruck. But:
- I would $num >>= 32;
- AIUI from earlier posts by knowledgeable people, the technique is valid for numbers such that the loop will always involve one or at most two iterations of the loop.
Update: s/16/32/ applied above, thanks GF.