A number system is a way of writing numbers using a fixed set of symbols called digits. Humans normally use the decimal number system, which has ten digits from 0 to 9, because we have ten fingers. However, a computer cannot count with fingers. It works with electricity, and an electric circuit can be in only two states — on or off. That is why a computer uses the binary number system, which has only two digits, 0 and 1. Besides decimal and binary, there are two other important number systems used in computing: the octal number system with eight digits and the hexadecimal number system with sixteen digits.
The decimal number system is also called the base-10 system because it uses ten digits, 0 to 9, and its base is 10. The position of a digit in a decimal number decides its place value. In the number 345, the digit 5 is in the units place, 4 is in the tens place, and 3 is in the hundreds place, so 345 means 3 hundreds plus 4 tens plus 5 ones. Mathematically, 345 = 3 x 100 + 4 x 10 + 5 x 1. Each place value is a power of 10: 10 to the power 0 is 1, 10 to the power 1 is 10, 10 to the power 2 is 100 and so on.
The binary number system is also called the base-2 system because it uses only two digits, 0 and 1, and its base is 2. Each 0 or 1 in a binary number is called a bit, and a group of 8 bits is called a byte. In a binary number, every place value is a power of 2: the units place is 2 to the power 0 which is 1, the next place is 2 to the power 1 which is 2, then 4, 8, 16, 32 and so on. For example, the binary number 1101 means 1 x 8 + 1 x 4 + 0 x 2 + 1 x 1, which equals 13 in decimal.
The octal number system is called the base-8 system because it uses eight digits from 0 to 7, and its base is 8. Digits 8 and 9 are never used in octal numbers. Each place value is a power of 8: 1, 8, 64, 512 and so on. For example, the octal number 17 means 1 x 8 + 7 x 1, which equals 15 in decimal. The octal system is used by computer programmers as a compact way of writing binary numbers, because one octal digit represents exactly three bits.
The hexadecimal number system is called the base-16 system because it uses sixteen digits: 0 to 9 for the values zero to nine, and the letters A, B, C, D, E and F for the values ten to fifteen. Each place value is a power of 16: 1, 16, 256 and so on. For example, the hexadecimal number 2A means 2 x 16 + 10 x 1, which equals 42 in decimal. One hexadecimal digit represents exactly four bits, so hexadecimal is the shortest and most compact way to write binary numbers, and it is used to write memory addresses and colour codes.
To convert a decimal number into binary, the number is divided repeatedly by 2, and the remainders are collected. The remainder of the last division becomes the first digit, and the remainders are read from bottom to top. For example, to convert 13 to binary: 13 divided by 2 gives remainder 1, 6 divided by 2 gives remainder 0, 3 divided by 2 gives remainder 1, and 1 divided by 2 gives remainder 1, so reading upward gives 1101. To convert binary back to decimal, multiply each digit by its place value and add: 1101 = 1 x 8 + 1 x 4 + 0 x 2 + 1 x 1 = 13.
Decimal to octal is converted by repeatedly dividing by 8 and reading the remainders from bottom to top. Decimal to hexadecimal is converted by repeatedly dividing by 16 and reading the remainders from bottom to top, writing letters A to F for remainders 10 to 15. The easiest way to convert between binary and octal is to group the binary digits into groups of three, starting from the right, and replace each group with its octal digit. Similarly, binary to hexadecimal is done by grouping the binary digits into groups of four and replacing each group with its hexadecimal digit.
Computers use binary because they are made of electronic circuits that can easily represent two states. A switch that is off represents 0 and a switch that is on represents 1. Data inside the computer travels as electric pulses, a low voltage meaning 0 and a high voltage meaning 1. This two-state system is simple, reliable and cheap to build. Storage devices such as hard disks also store data as magnetic patterns of two kinds. This is why every character, number, picture and sound inside the computer is ultimately stored as a long series of 0s and 1s.
| Number System | Base | Digits Used | Used By |
|---|---|---|---|
| Decimal | 10 | 0 to 9 | Humans for everyday counting |
| Binary | 2 | 0 and 1 | Computer internal processing |
| Octal | 8 | 0 to 7 | Compact writing of binary |
| Hexadecimal | 16 | 0-9 and A-F | Memory addresses and colours |
| Number System | Place Values | Example | Decimal Value |
|---|---|---|---|
| Binary | 1, 2, 4, 8, 16 | 1101 | 13 |
| Octal | 1, 8, 64, 512 | 17 | 15 |
| Hexadecimal | 1, 16, 256 | 2A | 42 |
| Decimal | 1, 10, 100 | 345 | 345 |
Number systems are the language of computing. Humans count in decimal, but computers store every value in binary using only 0 and 1. Octal and hexadecimal systems help us write long binary numbers in a short and readable form. With conversion skills between these four systems, we understand how data is stored inside the machine. Next, we explore the operating system, which is the master program that manages the whole computer and all the files created by these systems.