3 ms·
Look at the binary representation of acc. 11 00 00 01 00 10 01 00 00 01 10 00 01 00 00 When you take each group of 2 bits (starting with the least sign
by what 16y ago
Look at the binary representation of acc.
11 00 00 01 00 10 01 00 00 01 10 00 01 00 00
When you take each group of 2 bits (starting with the least significant group) and take the bitwise AND with 3, you'll get 0, 1, 2 or 3 (obviously). When you run those results through the print statement, you'll get the correct pattern of Fizz Buzzes for the numbers 1-15. This pattern of Fizz Buzzes will repeat. So, acc >> 2 | c << 28 moves the last 2 bits to the front, making the pattern of bits repeat. After 15 iterations of the loop, acc will be 810092048 again.
Communication isn't my strong point, so I hope that makes sense.
- shawndumas 16y agoif only i could up-vote twice... thanks!