Number Systems — worked example
Digital Logic 101 · Number Systems · Example
Convert into binary, octal, hex, BCD, and Gray code. Each base reuses the same value, and the conversions all go through the binary representation.
- Binary by repeated division. Divide by two; record the remainder; feed the quotient back. Read the remainders bottom-to-top.Remainders bottom-up: .
- Hex by regrouping. Split the 8-bit binary into two nibbles, then translate each nibble (0..15) into one hex digit (0..F).Cross-check: .
- Octal by regrouping. Pad the binary with a leading zero to a multiple of three bits, then split into 3-bit groups.Cross-check: .
- BCD digit-by-digit. Encode each decimal digit of independently in 4 bits.Note that BCD is wider than straight binary: 12 bits versus 8 bits. The trade-off is human-readable digits at the cost of bit density.
- Gray by XOR. Apply bit-wise.So . The XOR collapses to one Gray bit-flip per increment in , which is the entire point of the encoding.
Pick the path that fits the target base. Binary is repeated division; hex and octal regroup the binary; BCD encodes decimal digits independently; Gray comes straight from an XOR of the binary value with itself shifted right.
Try other values in the Simulate stage — every field updates live as you type or toggle bits.