Four number systems
Computers store everything as binary (base 2), yet people find long strings of 0s and 1s hard to read. That is why we also use octal (base 8) and hexadecimal (base 16) as shorter ways of writing the same value. A number system's base tells you how many different digits it uses.
- Binary (base 2): digits 0-1
- Octal (base 8): digits 0-7
- Decimal (base 10): digits 0-9
- Hexadecimal (base 16): digits 0-9 then A-F, where A=10 ... F=15
Key idea
To convert to decimal, multiply each digit by its place value (a power of the base) and add the results.
Converting between bases
Because 8 = 23 and 16 = 24, binary groups neatly: three bits make one octal digit and four bits make one hexadecimal digit.
Example
Convert 2F16 to decimal: (2 × 16) + 15 = 47. Convert 1011102 to octal by grouping three bits from the right: 101 110 → 568. Convert the same binary to hexadecimal by grouping four bits: 0010 1110 → 2E16.
A useful habit
When grouping bits, always start from the right and add leading zeros to complete the left-most group. Check your answer by converting back to decimal - 568, 2E16 and 1011102 all equal 46.
Remember
- Octal never uses the digits 8 or 9.
- Hexadecimal uses letters A-F for 10-15.
- Group 3 bits for octal, 4 bits for hexadecimal.