in reply to Re^2: decimal to binary
in thread decimal to binary
The key is $dec >>= 1; which shifts $dec one bit right - that is, it moves all the bits one position down and the previous least significant bit "drops off the end". A 0 bit is shifted in as the most significant bit so eventually all the one bits have been shifted out and the while loop ends.
The || !@bits makes sure that there is at least one bit in @bits by executing the loop once when $dec is 0.
I'd guess join and maybe push are new to you. I've provided links to documentation for them.
|
|---|