A Computer Number System is a method used to represent numbers within a computer. These systems are essential for storing and processing data.
Number system conversion is an important topic in Computer Science and competitive examinations. The following sections explain commonly used conversion methods with examples.
To convert a binary number to decimal, multiply each binary digit by its corresponding power of 2 and add the results. The rightmost digit has the power 0.
Step 1: Write the binary number:
1 1 1 1 0
Step 2: Assign powers of 2 from right to left:
24 23 22 21 20
Step 3: Calculate the powers:
16 8 4 2 1
Step 4: Multiply and add:
(1 × 16) + (1 × 8) + (1 × 4) + (1 × 2) + (0 × 1)
= 16 + 8 + 4 + 2 + 0
= 30
Therefore, (11110)2 = (30)10
There are two common methods:
Using the powers of 2 method:
Powers of 2: 16 8 4 2 1
25 − 16 = 9
9 − 8 = 1
1 − 1 = 0
Therefore: 1 1 0 0 1
(25)10 = (11001)2
To convert an octal number to binary, replace each octal digit with its corresponding 3-bit binary equivalent.
5 = 101
3 = 011
7 = 111
(101 011 111)2
(537)8 = (101011111)2
Group the binary digits into sets of three from right to left. Add leading zeros if necessary and convert each group into its octal equivalent.
Step 1: Group the binary digits:
001 010 111 100
Step 2: Convert each group:
001 = 1
010 = 2
111 = 7
100 = 4
(1010111100)2 = (1274)8
Convert each hexadecimal digit into its corresponding 4-bit binary equivalent.
5 = 0101
A = 1010
D = 1101
(0101 1010 1101)2
(5AD)16 = (010110101101)2
Group binary digits into sets of four from right to left. Add leading zeros if required and convert each group into hexadecimal.
Step 1: Group into sets of four:
0001 0101 0110 1001
0001 = 1
0101 = 5
0110 = 6
1001 = 9
(1010101101001)2 = (1569)16
For conversion between octal and hexadecimal, binary can be used as an intermediate number system.
Step 1: Octal → Binary
4 = 100
6 = 110
(100110)2
Step 2: Binary → Hexadecimal
0010 0110
0010 = 2
0110 = 6
(46)8 = (26)16
Divide the decimal number repeatedly by 8 and read the remainders from bottom to top.
1234 ÷ 8 = 154 remainder 2
154 ÷ 8 = 19 remainder 2
19 ÷ 8 = 2 remainder 3
2 ÷ 8 = 0 remainder 2
Reading the remainders from bottom to top:
(1234)10 = (2322)8
Divide the decimal number repeatedly by 16. Use A–F for decimal values 10–15 and read the remainders from bottom to top.
1234 ÷ 16 = 77 remainder 2
77 ÷ 16 = 4 remainder 13 (D)
4 ÷ 16 = 0 remainder 4
(1234)10 = (4D2)16
Multiply each octal digit by its corresponding power of 8 and add the results.
(1 × 82) + (2 × 81) + (5 × 80)
= (1 × 64) + (2 × 8) + (5 × 1)
= 64 + 16 + 5
(125)8 = (85)10
Multiply each hexadecimal digit by its corresponding power of 16. Use the decimal values of A–F.
C = 12, A = 10, F = 15, E = 14
(12 × 163) + (10 × 162) + (15 × 161) + (14 × 160)
= 49152 + 2560 + 240 + 14
(CAFE)16 = (51966)10
For digits after the decimal point, use negative powers of 2: 2-1, 2-2, 2-3, and so on.
(1 × 2-1) + (0 × 2-2) + (1 × 2-3) + (1 × 2-4)
= 0.5 + 0 + 0.125 + 0.0625
(0.1011)2 = (0.6875)10
Whole part: (1101)2 = (13)10
Fractional part: (0.1011)2 = (0.6875)10
Therefore, (1101.1011)2 = (13.6875)10
To convert a decimal fraction to binary, repeatedly multiply the fractional part by 2. Record the integer part at each step. Read the integer parts from top to bottom.
0.375 × 2 = 0.750 → 0
0.750 × 2 = 1.500 → 1
0.500 × 2 = 1.000 → 1
(0.375)10 = (0.011)2
Whole part: (23)10 = (10111)2
Fractional part:
0.15 × 2 = 0.30 → 0
0.30 × 2 = 0.60 → 0
0.60 × 2 = 1.20 → 1
0.20 × 2 = 0.40 → 0
0.40 × 2 = 0.80 → 0
0.80 × 2 = 1.60 → 1
The fractional part repeats, so the binary representation is a repeating fraction.
(23.15)10 ≈ (10111.001001...)2
To convert a decimal fraction to another base, multiply the fractional part repeatedly by the target base. For octal, multiply by 8.
0.37 × 8 = 2.96 → 2
0.96 × 8 = 7.68 → 7
0.68 × 8 = 5.44 → 5
(0.37)10 ≈ (0.275)8
Binary arithmetic uses only two digits: 0 and 1. Binary addition and subtraction are important for understanding how computers represent and process data.
| Operation | Result | Carry |
|---|---|---|
| 0 + 0 | 0 | 0 |
| 0 + 1 | 1 | 0 |
| 1 + 0 | 1 | 0 |
| 1 + 1 | 0 | 1 |
| 1 + 1 + 1 | 1 | 1 |
1011
+ 0110
------
10001
(1011)2 + (110)2 = (10001)2
| Operation | Result | Borrow |
|---|---|---|
| 0 − 0 | 0 | 0 |
| 1 − 0 | 1 | 0 |
| 1 − 1 | 0 | 0 |
| 0 − 1 | 1 | 1 |
1010
- 0101
------
0101
Therefore, (1010)2 − (101)2 = (101)2