How number bases work
A number base says how many digits there are before you carry to the next place. Decimal (base 10) has ten, 0 to 9. Binary (base 2) has two, 0 and 1. Octal (base 8) uses 0 to 7, and hexadecimal (base 16) uses 0 to 9 and then the letters a to f for ten to fifteen. Bases above 16 carry on through the alphabet, up to base 36, which uses every digit and letter.
Each place is worth the base times the place to its right. In hex, 1f is 1 sixteen plus 15 ones,
which is 31 in decimal. In binary, 1010 is 8 + 2, which is 10.
Hex, binary and bytes
One hex digit is exactly four binary digits (bits), and two hex digits are one byte. That's why hex is the
usual way to write raw bytes, memory addresses, colours and hash values: ff is the byte
1111 1111, or 255. Octal digits are three bits each, and are still used for Unix file
permissions such as 755.
What you can type
Prefixes like 0x, 0b and 0o are optional, letters can be upper or
lower case, and spaces, underscores and commas between digits are ignored, so 0xDEAD_BEEF and
1,000,000 both work. Numbers can be any size, up to 10,000 digits.
Negative numbers and two's complement
With no bit width, a negative number is written with a minus sign in every base: −10 is -a in
hex. Computers store negatives as two's complement instead, in a fixed number of bits: −1 is
ff as an 8-bit number and ffffffff as a 32-bit one. Pick a bit width to see
numbers that way. Decimal then shows the signed value, and the line below the fields shows both the signed
and the unsigned value, so ff reads as −1 or 255.