Home / Notes / Class 9 / Computer Science / Number systems
Decimal, binary, octal and hexadecimal number systems, conversion between them, binary addition, complements, and how computers store characters using ASCII and Unicode, with worked examples.
A number system is a way of writing numbers using a fixed set of symbols called digits. The base (or radix) of a system is the number of different digits it uses. Each digit has a value that depends on its place, so these are called positional number systems.
The four number systems used in computing are:
Computers use binary because electronic circuits have two clear states: on and off (or high and low voltage). These two states are easy to build, store and detect, and they are less likely to be misread than ten different levels. One binary digit is called a bit. Four bits make a nibble and eight bits make a byte.
In any positional system the value of a digit is the digit multiplied by the base raised to the power of its position. Positions are counted from the right, starting at 0. For example, in the decimal number 352, the value is 3 × 10² + 5 × 10¹ + 2 × 10⁰ = 300 + 50 + 2.
Binary to decimal: multiply each bit by 2 raised to its position and add the results. Example: 1011 in binary.
Decimal to binary: divide the number by 2 again and again and write the remainders. Read the remainders from bottom to top. Example: 13.
The same division method works for other bases. To convert a decimal number to octal divide by 8, and to hexadecimal divide by 16. Write the remainders from bottom to top, using letters A to F for remainders 10 to 15.
Binary, octal and hexadecimal are linked by grouping bits:
Hexadecimal is popular because it is a short way to write long binary numbers. One hex digit stands for exactly four bits, so a byte is just two hex digits. It is used for colour codes in web pages, memory addresses and MAC addresses.
Binary addition follows four rules:
Negative numbers can be shown using complements. The 1's complement is found by changing every 0 to 1 and every 1 to 0. The 2's complement is the 1's complement plus 1. Computers use 2's complement to store negative integers and to do subtraction by addition.
Computers also store letters and symbols as numbers. ASCII (American Standard Code for Information Interchange) uses 7 bits to represent 128 characters, for example capital A has the code 65 and a has 97. Extended ASCII uses 8 bits for 256 characters. Unicode uses more bits and can represent characters of many languages including Urdu.
Study tip: Practise conversions every day because they carry sure marks. Always show the division steps or the power of 2 steps, and check the answer by converting back. Memorise the powers of 2 up to 2⁸ (1, 2, 4, 8, 16, 32, 64, 128, 256) and the hex letters, which will make working fast.
Say the meaning first, then open the card to check.
The number of different digits in a number system.
A binary digit, 0 or 1.
A group of 8 bits.
The base 2 number system using 0 and 1.
The base 16 system using 0 to 9 and A to F.
The base 8 system using digits 0 to 7.
A binary number with every bit flipped.
A code that gives each character a number, using 7 bits for 128 characters.
A character code that covers the writing systems of many languages.
| Name | Formula | What it means |
|---|---|---|
| Value of a digit | digit × base^position | Position is counted from the right starting at 0 |
| Binary to decimal | d₃ × 2³ + d₂ × 2² + d₁ × 2¹ + d₀ × 2⁰ | Add the weighted bits |
| 2's complement | 1's complement + 1 | Used to represent negative numbers |
| Characters in n bits | 2ⁿ | 7 bits give 128, 8 bits give 256 |
These are the kind of questions asked for 2, 3 and 5 marks. Try each one before opening the answer.
Computer circuits have two stable states, on and off, which match the digits 1 and 0. Two states are simple and cheap to build and are reliable because they are hard to confuse. Because of this all data is stored and processed in binary.
The base is the number of different digits a number system uses. Binary has base 2, octal has base 8 and hexadecimal has base 16.
10 = A, 11 = B, 12 = C, 13 = D, 14 = E and 15 = F.
Start from the right and make groups of four bits. If the last group has fewer than four bits, add zeros on the left. Write the hex digit for each group using its value from 0 to 15, with A to F for 10 to 15. Joining these digits gives the hexadecimal number. For example, 1010 1111 becomes AF.
ASCII is a standard code that assigns a number to each letter, digit and symbol so that computers can store and exchange text. Standard ASCII uses 7 bits and can represent 128 characters. Extended ASCII uses 8 bits and represents 256.
The 1's complement is found by flipping each bit, so 10110 becomes 01001. The 2's complement is 01001 + 1 = 01010.
Answer: (101101)₂
Answer: (27)₁₀
Answer: (B6)₁₆
Answer: (11000)₂
Answer: (47)₁₀