Number System Conversation (Fully Explained With Questions) .
Number System Conversation (Fully Explained With Questions) .
Introduction
0, 1, 2, 3, ..., b-1
N = an an-1... a1 a0
N = an × bn + an-1×bn-1 + ... + a2 × b2 + a1 × b1 + a0 × b0
17
Computer Basics
Decimal System
The powers of ten,
This decimal fraction is said to have three decimal places, the number of
digits to the right of the decimal point.
The place values in the binary system are the powers of the base b=2,
just as the place values in the decimal systems are the powers of ten.
18
N u m b e r S y ste m s
Specifically, the place values of the integral part of a binary number are
the nonnegative powers of two.
20 21 22 23 ...
and the place values of the fractional part of a binary number are the
negative powers of two,
Table 1.1.
2-4 0.0625
2-3 0.125
2-2 0.25
2-1 0.5
20 1
21 2
22 4
23 8
Since 8 = 23, each octal digit has a unique 3-bit binary representation,
given in Table 1.2.
Table 1.2
19
Computer Basics
The place values in the octal system are powers of 8; some of the these
powers appear in Table 1.3.
Table 1.3
20
N u m b e r S y ste m s
1. 7 Exercise
i) 2
ii) 8
iii) 10
iv) 16.
b. The place values of the fractional part of a binary number are the
i) nonnegative powers of 2
ii) negative powers of 2
iii) negative powers of 10
iv) negative powers of 8.
2. Analytical questions
21
Computer Basics
110101 = 1 × 25 + 1 × 24 + 0 × 23 + 1 × 22 + 0 × 21 + 1 × 20
Table 1.6 lists the binary representations of the integers from 0 to 25,
with the place of the bits shown at the top of the table. Sometimes a
subscript 2 is used to distinguish a binary number, e.g. one may write
1010112 if it is not clear from the context that 101011 is a binary number
rather than a decimal number. Also, for easier reading, one sometimes
separates a binary number into 4-bit groups, to the left and right of the
binary point; e.g.
22
N u m b e r S y ste m s
Table 1.6
Example 2.1:
Place values 25 24 23 22 21 20
Binary number 1 1 0 1 0 1
1
4
16
32
Decimal equivalent 53
23
Computer Basics
(b) To convert 101.11012 to its decimal equivalent, use Table 1.1 for
the decimal values of the negative powers of two
0.0625
0.25
0.5
1
4
Decimal equivalent 58125
.
2.3 Decimal-to-Binary Conversion
It is possible to find binary representation of a decimal number N by
converting its integral part (NI), and its fractional part (NF) separately. It
is illustrated with the decimal number N = 109.78125.
Example 2.2
The zero quotient indicates the end of the calculations. The sequence of
remainders from the bottom to up, as indicated by the arrow, yields the
required binary equivalent. That is NI = 109 = 11011012.
24
N u m b e r S y ste m s
Here stop when the quotient, 1, is less than the divisor 2, since this last
quotient will be next and last remainder. Again the arrow indicates the
sequence of bits that gives the binary equivalent of the number.
0.781 25
×2
1.562 50
×2
1.125 00
×2
0.250 00
×2
0.500 00
×2
1.000 00
It is found that the binary equivalents of the integral and fractional parts
of the decimal number N = 109.78125. The binary equivalent of N is
simply the sum of these two equivalents:
N = NI + NF = 1101101.11001
25
Computer Basics
Example 2.3 :
Let, N = 13.6875. Convert the integral part, NI = 13, and the fractional
part, NF = 0.6875, into binary forms :
2)13 0.6875
2)6 1 ×2
2)3 0 1.3750
1 1 ×2
0.7500
×2
1.5000
×2
1.0000
At this point in the procedure, one can again multiply 0.6 by 2. This
means the above four steps will be repeated again and again. That is,
(The number of bits which repeat is not always four; nor does the
repeating block necessarily begin at the binary point, it depends on the
given N.)
26
N u m b e r S y ste m s
Example 2.4 :
7
×16
112
+3
115
×16
1840
+13
1853
×16
29648
+5
29653 = 73D516
27
Computer Basics
0.78125 × 16 = 12.50000 12
0.50000 × 16 = 8.00000 8
N = P + Q = 25F7.C816
Hexadecimal-Binary Interconversion
Example 2.5 :
Hexadecimal-Binary Inter-
conversion
Convert to binary form (a) 3D5916, (b) 27.A3C16.
(a) 3D59
(b) 27.A3C
28
N u m b e r S y ste m s
Example 2.6 :
Partition each binary number into 4-bit blocks to the left and right of the
binary point adding 0s if necessary. Then replace each 4-bit block by its
equivalent hexadecimal digit (Table 1.4).
2D2E
1 C. B 6 C
2.5 Exercise
i) 8
ii) 10
iii) 12
iv) 14.
i) 15
ii) 18
iii) 22
iv) 24.
29
Computer Basics
i) 1001102
ii) 11110012
iii) 11011012
iv) 11101012.
i) 1719
ii) 9610
iii) 9719
iv) 09919.
2. Analytical questions
i) 101012
ii) 1001012
iii) 1011.1012
iv) 101.11012.
i) 653.625
ii) 13.6875
iii) 367
iv) 235.07.
i) 129A.B8616
ii) 73D516
iii) 0.782516
iv) 39.C816.
i) 129A.B8616
ii) 3D5916.
i) 101101001011102
ii) 101101101110.10001102.
30
N u m b e r S y ste m s
Binary Addition Step 2. Record the unit digit of the column sum. If the sum exceeds
one, carry the two's digit 1, to the next column.
The addition table for the binary digits 0 and 1 appears as Table 1.7 the
only additional facts needed for binary addition appear in Table 1.8.
+ 0 1 0+0=0
0 0 1 0+1=1
1 1 10 1+0=1
1 + 1 = 0, with a carry of 1
1 + 1 + 1 = 1, with a carry of 1
Table 1.7 Binary Addition
Table 1.8 Binary Addition Facts
Example 3.1 :
31
Computer Basics
STEP 3: 1 + 0 =1.
STEP 2.
111 Carries
111 Addend
+101 Augend
1100 Sum
Step 3. Stop.
Example 3.4 :
1101011
× 10110
0000000
1101011
1101011
0000000
1101011
Then add the five bottom rows of numbers. In actual practice, one does
not write down any zero products. Finally bring down initial zero, if any
and form a running total, adding one nonzero row after another :
32
N u m b e r S y ste m s
Binary Subtraction Step 1. If the lower (subtrahend) digit is greater than the upper
(minuend) digit, borrow from the next column to the left.
The only subtraction facts needed for binary subtraction are the four
listed in Table 1.9.
10 - 1 = 1
Example 3.5 :
11101
- 1011
10010
33
Computer Basics
Example 3.6 :
Obtain,
011
11000
- 10011
101
Example 3.7 :
00110 01
1100101001
- 110110110
101110011
Example 3.8 :
Calculate 42558 ÷ 123. Here 123 is the divisor. The algorithm for
division yields :
34
N u m b e r S y ste m s
346
123)42558
369
565
492
738
738
0
That is, multiply 123 by 3 and subtract the product, from 425; then
multiply 123 by 4 and subtract the product 492, from 565; lastly multiply
123 by 6 and subtract the product 738, from 738, to obtain a 0
remainder. [Because of the geometry of the scheme, what these steps
actually accomplish is first to subtract 3 × 102 times the divisor from the
dividend, then 4 × 10 times the divisor from what is left, and then 6
times the divisor from what is left. At that point the dividend is
exhausted, showing that the dividend originally contained the divisor
3 ×102 + 4 × 10 + 6 =346 times].
The above algorithm also works for binary division. In fact, multiplying
the divisor by the only nonzero digit, 1, does not change the number;
hence the algorithm for division reduces to repeated subtraction of the
divisor (times a power of 2).
Example 3.9 :
11011
11)1010001
11
100
11
100
11
11
11
0
Thus the quotient is 11011.
35
Computer Basics
Example 3.10 :
1101
1001)1110111
1001
1011
1001
1011
1001
10
3.5 Complements
There are two types of complements, the one's complement and two's
complement, respectively.
Example 3.11 :
36
N u m b e r S y ste m s
Observe that taking the ones complement simply inverts each digit, i.e. 0
is replaced by 1 and 1 is replaced by 0.
Example 3.12 :
011
11110000 B
-10001110 A
01100010 Y
Observe that the borrowing was propagated to the third digit to the left.
11110000 B
+ 01110001 One's complement of A
01100001
1
01100010
11110000 B
+01110010 Two's complement of A
01100010
Deleting the 1 (which would be an overflow in an 8-bit register) gives
the difference Y.
37
Computer Basics
3.6 Exercise
i) 2 step algorithm
ii) 3 step algorithm
iii) 4 step algorithm
iv) 5 step algorithm.
i) addition
ii) subtraction
iii) multiplication
iv) conversion.
2. Analytical questions
i) 10010 - 11011
ii) 10101 - 00110
iii)11101 - 1011.
i) 11010011 ÷ 11
ii) 11110111 ÷ 1001.
38
N u m b e r S y ste m s
i) 1011012
ii) 1111000011112
iii) 909010
iv) 10101012.
i)11011 - 10010
ii)10001110 - 11110000
iii) 10101 - 00110.
39