created: 07/15/2015
Clear: | |
---|---|
Original Decimal: | |
Number: | |
Divide Number by Two: | |
Number Div Two: | |
Number Mod Two: | |
Bit String: | |
Repeat: |
To start: Enter a decimal representation of an integer in the "Number" box.
Then: Click "Divide by Two" to compute the quotient and remainder. The remainder will be 0 or 1. That bit is copied to the left of the bit string.
Click "Repeat" to go through the cycle again. Quit when the number has been reduced to zero.
The algorithm is:
number = positive integer ; bitstring = "" while (number > 0 ) { bit = number mod 2 ; quotient = number div 2 ; put bit to the left of any previous bits in the bitstring ; number = quotient ; }