You must understand the so called bit shift operator (>>) which moves the bits of the input to lower side. So a repeating call moves all bits out of the memory.
This operator moves the bits
of the memory which is interpreted as some variable. To really understand it you must understand that all bits are in the memory and the actual value is the interpretation
of that memory. Easiest to understand with strings. Some explaation with some sample code from Microsoft
I found a really nice implementation of your task on stack overflow
. The results is nicely stored in string buffers.