Convert between binary, octal, decimal, and hexadecimal
Digital systems use binary (base-2) because transistors have two stable states. Hexadecimal (base-16) is the standard shorthand — each hex digit maps exactly to 4 binary bits, making register values and memory addresses compact and readable.
Binary → Hex: group bits into nibbles (4 bits) from the right; each nibble = one hex digit. Decimal → Binary: repeatedly divide by 2 and collect remainders from bottom up.
Microcontrollers represent negative integers in two's complement: invert all bits then add 1. For 8-bit: −1 = 0xFF, −128 = 0x80. The MSB is the sign bit.