Repeated division converts a decimal number into any base b. It's the standard method for decimal → binary, octal or hex.
- Divide the number by b. Write down the remainder (0 to b − 1).
- Replace the number with the quotient.
- Repeat until the quotient is 0.
- Read the remainders from last to first. The first remainder is the rightmost digit.
Why it works: dividing by 2 is like pairing things up. Whatever is left over after pairing is the 1s bit. Pair up the pairs, and the leftover is the 2s bit, and so on. The smallest bundle is found first, which is why the first remainder is the LSB.
For hex, divide by 16 and write remainders of 10–15 as the letters A–F. Each remainder is one digit, even if it's 12. For octal, divide by 8.