Number Systems
Chapter
1
1.1 Introduction
A digital system is a combination of devices designed to manipulate physical
quantities or information that are represented in digital form, that, is they can
only take discrete values. A digital system includes digital computers, calculators,
telephone system and digital audio and video equipment.
Advantages of digital techniques over analog
• Easier to design
• Generally the information is stored in the form of 1’s and 0’s, hence easier
to store any data.
• Digital circuits are less affected by noise as noise is analog in nature.
• Processing and reprogramming is possible
in digital circuits.
• Power dissipation is less.
• Less bulky and less cost.
FACT: World’s largest
known digital system is
telephone system.
Limitation of digital technique
• Real world is mainly analog. So, digital data needs to be converted into
analog form for human understanding.
1.2 Digital Electronics, an easy approach to learn
1.2 Number Systems
Number systems are introduced mainly to quantify the magnitude of something.
So we can say that number system gradually evolved with the concept of counting.
There are many number systems out of which the most frequently used are:
• Decimal number system
• Binary number system
• Octal number system and
• Hexadecimal number system.
FACT: We generally use
decimal number system in
our day-to-day life.
A number (N)b is represented as,
(N)b = dn−1dn−2dn−3....d1d0
integral portion
·
radix
point
d−1d−2d−3....d−m
fractional portion
Where,
N = number
b = base or radix
d = different symbols used in the number system
n = number of digits in the left side of the radix point
m = number of digits in the right side of the radix point
Radix is defined as the number of different symbols used in a particular num-
ber system. For example, in decimal number system, the base is 10. So, we use
10 different symbols (digits) 0, 1, 2, 3, 4....8, 9 to represent any decimal number.
Note:
The maximum value of digit in any number system is given by (b − 1).
For example, maximum value of digit in decimal number system = (10 -1) = 9
Any number system can be converted into decimal number system by using
the following formula:
Decimal equivalent = dn−1(b)n−1 + dn−2(b)n−2 + ...... + d1(b)1 + d0(b)0+
d−1(b)−1 + d−2(b)−2 + ........ + d−m(b)−m
1.2.1 Binary number system
It is a simple number system as it consists of only 2 digits (symbols), 0 and 1.
Hence, it is called as base-2 number system or binary number system.
For example, (1011101)2, (101011.101)2, etc.
Number Systems 1.3
Decimal - binary conversion
Conversion of decimal number to binary number
A decimal number can be easily converted into binary number by dividing the
decimal number by 2 progressively, until the quotient of zero is obtained. The bi-
nary number is obtained by taking the remainder after each division in the reverse
order. The examples discussed below will best describe the conversion.
Example 1.1 Convert the decimal number (23)10 into its equivalent binary num-
ber.
Solution
Taking the remainders from bottom to top, the equivalent binary number can be
written as (10111)2.
Example 1.2 Convert the decimal number (18.125)10 into its equivalent binary
number.
Solution
The integral part and the fractional part are computed separately.
Integral conversion:
2
2
2
2
18
9
4
2
1
-
-
-
-
0
0
1
0
Top
Bottom
(18)10 = (10010)2
Fractional conversion:
If the decimal number contains a fractional part, then its binary equivalent is ob-
tained by multiplying the fractional part continuously by 2, removing the carry
1.4 Digital Electronics, an easy approach to learn
over (whether 0 or 1) in the integer position each time. The removed carry over in
forward order gives the required binary number.
0.125
0.250
0.500
× 2
× 2
× 2
1.000
Forward
order
(0.125)10 = (0.001)2
Hence, (18.125)10 = (10010.001)2
Example 1.3 Convert the decimal number (12.1)10 into its binary equivalent.
Solution
Integral conversion:
2
2
2
12
6
3
1
-
-
-
1
0
0
Top
Bottom
Fractional conversion:
0.1
0.2
0.4
× 2
× 2
× 2
× 2
× 2
× 2
× 2
× 2
× 2
0.8
1.6
1.2
0.4
0.8
1.6
1.2
Forward
order
Number Systems 1.5
Hence,
(12.1)10 = (1100.000110011....)2
= (1100.00011)2
Conversion of binary to decimal number
We know that any number system can be converted into decimal number system
by using the formula:
Decimal equivalent = dn−1(b)n−1 + dn−2(b)n−2 + ...... + d1(b)1 + d0(b)0+
d−1(b)−1+d−2(b)−2+........+d−m(b)−m
Example 1.4 Convert the binary number (10110)2 into its decimal equivalent.
Solution
Base, b = 2
n = number of digits = 5
Hence by using the formula,
Decimal equivalent = (1 × 24
) + (0 × 23
) + (1 × 22
) + (1 × 21
) + (0 × 20
)
= 16 + 0 + 4 + 2 + 0
= 22
So, (10110)2 = (22)10
Example 1.5 Convert the binary number (111001)2 into its decimal equivalent.
Solution
Base, b = 2
n = number of digits = 6
Hence by using the formula,
Decimal equivalent = (1 × 25
) + (1 × 24
) + (1 × 23
) + (0 × 22
)
+ (0 × 21
) + (1 × 20
)
= 32 + 16 + 8 + 0 + 0 + 1
= 57
So, (111001)2 = (57)10
1.6 Digital Electronics, an easy approach to learn
Example 1.6 Convert the binary number (10000.1011)2 into its decimal equiv-
alent.
Solution
Base, b = 2
n = number of digits = 5 (considering only integral part)
Hence by using the formula,
Decimal equivalent = (1 × 24
) + (0 × 23
) + (0 × 22
) + (0 × 21
) + (0 × 20
)
+ (1 × 2−1
) + (0 × 2−2
) + (1 × 2−3
) + (1 × 2−4
)
= 16 + 0 + 0 + 0 + 0 + 0.5 + 0 + 0.125 + 0.0625
= 16.6875
So, (10000.1011)2 = (16.6875)10
2 Concept: Any decimal number can be converted to any other number system by
dividing the decimal number by the base of the other number system progressively,
until the quotient of zero is obtained and taking the remainder after each division in
reverse order.
For example, while converting decimal to binary, we divide the decimal number pro-
gressively by 2.
1.2.2 Octal number system
The octal number system uses 8 different symbols 0, 1, 2, 3....6, 7. Its base is 8.
Octal - decimal conversion
Conversion of decimal to octal
It is similar to decimal to binary conversion. For integral decimal, the number is
repeatedly divided by 8 and for fraction, the number is multiplied by 8.
Example 1.7 Convert the decimal number (78)10 into its equivalent octal num-
ber.
Solution
8
8
78
9
1
-
- 1
6
Top
Bottom
Number Systems 1.7
Taking the remainders from bottom to top, the equivalent octal number can be
written as (116)8.
Example 1.8 Convert the decimal number (321.456)10 into its equivalent octal
number.
Solution
The integral part and the fractional part are computed separately.
Integral conversion:
8
8
321
40
5
-
- 0
1
Top
Bottom
Fractional conversion:
Terminate the process after 5-6 multiplications
(More number of multiplications increases the accuracy of the answer)
Hence, (321.456)10 = (501.3513615)8
Conversion of octal to decimal
Example 1.9 Convert the octal number (6327.4051)8 into its decimal equiva-
lent.
Solution
We know that any number system can be converted to decimal number system by
using the formula:
1.8 Digital Electronics, an easy approach to learn
Decimal equivalent = dn−1(b)n−1 + dn−2(b)n−2 + ...... + d1(b)1 + d0(b)0+
d−1(b)−1+d−2(b)−2+........+d−m(b)−m
Here, Base, b = 8
n = number of digits = 4(consider only integral part)
Hence by using the formula,
Decimal equivalent = (6 × 83
) + (3 × 82
) + (2 × 81
) + (7 × 80
) + (4 × 8−1
)
+ (0 × 8−2
) + (5 × 8−3
) + (1 × 8−4
)
= 3072 + 192 + 16 + 7 +
4
8
+ 0 +
5
512
+
1
4096
= 3287.510098
So, (6327.4051)8 = (3287.5100098)10
1.2.3 Hexadecimal number system
The hexadecimal number system has a base of 16 and uses 16 different symbols,
namely (0, 1, 2, 3, 4.....8, 9, A, B, C, D, E, F).
Where, A = 10
B = 11
C = 12
D = 13
E = 14
F = 15
FACT: Microprocessor deals
with instruction and data that
uses hexadecimal number sys-
tem, for programming purposes.
Since this system contains both numeric digits and alphabets, this is called as
alphanumeric number system.
Hexadecimal - decimal conversion
Conversion of decimal to hexadecimal
It is similar to decimal-binary conversion. For integral part, the decimal num-
ber is repeatedly divided by 16 and for fractional part, the number is repeatedly
multiplied by 16.
Number Systems 1.9
Example 1.10 Convert the decimal number (156.625)10 into its equivalent hex-
adecimal number system.
Solution
The integral part and the fractional part are computed separately.
Integral conversion:
16 156
9 - C
Top
Bottom
Fractional conversion:
0.625
A.000
× 16Forward
order
Hence, (156.625)10 = (9C.A)16
Conversion of hexadecimal to decimal
Example 1.11 Convert (3DB)16 into decimal equivalent.
Solution
n = 3; b = 16
Decimal equivalent = (3 × 162
) + (D × 161
) + (B × 160
)
= (3 × 162
) + (13 × 161
) + (11 × 160
)
= 768 + 208 + 11
= 987
So, (3DB)16 = (987)10
Conversion between octal - hexadecimal - binary - decimal
Example 1.12 Convert (189)10 into its equivalent octal, hexadecimal and bi-
nary forms.
1.10 Digital Electronics, an easy approach to learn
Solution
Binary conversion:
So, (189)10 = (10111101)2
Octal conversion:
8
8
189
23
2
-
- 7
5
Top
Bottom
So, (189)10 = (275)8
Hexadecimal conversion:
16 189
11 - 13
Top
Bottom
So, (189)10 = (BD)16
Example 1.13 Convert (110111001)2 into its equivalent base 8, base 10, and
base 16 number system.
Solution
Octal conversion:
There are two methods of binary to octal conversion.
Method 1:
Convert the binary number into its decimal equivalent and then convert the deci-
mal into octal.
Number Systems 1.11
(110111001)2;
Here, n = 9, b = 2
Decimal equivalent = (1 × 28
) + (1 × 27
) + (0 × 26
) + (1 × 25
) + (1 × 24
)
+ (1 × 23
) + (0 × 22
) + (0 × 21
) + (1 × 20
)
= 441
Now, (441)10 can be converted into octal
8
8
441
55
6
-
- 7
1
Top
Bottom
So, (110111001)2 = (441)10 = (671)8
Method - 2
2 Concept: Octal has base 8 i.e. 23
. So, make a grouping of 3 binary bits from right
hand side in order to obtain the corresponding octal number.
(110 111 001)2
6 7 1
Hence, (110111001)2 = (671)8.
Hexadecimal conversion:
A binary number can also be converted into hexadecimal in 2 ways as stated above
for octal conversion.
Method 1:
Convert the binary number into its decimal equivalent and then convert the deci-
mal into hexadecimal.
(110111001)2; n = 9, b = 2
Decimal equivalent = (1 × 28
) + (1 × 27
) + (0 × 26
) + (1 × 25
) + (1 × 24
)
+ (1 × 23
) + (0 × 22
) + (0 × 21
) + (1 × 20
)
= 441
Now, (441)10 can be converted into hexadecimal
1.12 Digital Electronics, an easy approach to learn
16
16
441
27
1
-
- 11
9
Top
Bottom
So, (110111001)2 = (441)10 = (1B9)16
Method - 2
2 Concept: Hexadecimal has a base 16 i.e. 24
. So, make a grouping of 4 binary bits
from right hand side inorder to obtain the corresponding hexadecimal equivalent for a
given binary number representation.
(110111001)2 = (0001 1011 1001)2
1 B 9
Hence, (110111001)2 = (1B9)16.
Example 1.14 Convert the octal number (172)8 into its corresponding binary,
decimal and hexadecimal equivalent.
Solution
Binary conversion:
(1 7 2)8
↓
001 111 010
So, (172)8 = (001111010)2
Decimal conversion:
n = 3, b = 8
Decimal equivalent = (1 × 82
) + (7 × 81
) + (2 × 80
)
= 64 + 56 + 2 = 122
So, (172)8 = (122)10
Hexadecimal conversion:
2 Concept: For conversion of octal to hexadecimal or hexadecimal to octal number
system, we need another number system like binary or decimal number system as an
intermediary number system in conversion. Taking binary number system as the inter-
mediary is easier.
Number Systems 1.13
Method - 1
Octal −→ decimal −→ hexadecimal
Method - 2 (easier)
Octal −→ binary −→ hexadecimal
From method - 2
(1 7 2)8 = (001111010)2
↓
001 111 010
(001 111 010)2 = (0000
0
0111
7
1010
A
)2
So, (172)8 = (07A)16
Example 1.15 Convert the binary number (1011011110.11001010011)2 into its
corresponding octal equivalent.
Solution
For left side of the radix point we group the bit from LSB (Least Significant Bit),
and if needed, we append additional 0 in the left most side,
(MSB) ←− 001
1
011
3
011
3
110
6
−→ (LSB)
For right side of the radix point we group the bit from MSB (Most Significant
Bit), and if needed, we append additional 0 in the right most side,
(MSB) ←− 110
6
010
2
100
4
110
6
−→ (LSB)
So, (1011011110.11001010011)2 = (1336.6246)8
Example 1.16 Convert the hexadecimal number (2F9A)16 into its correspond-
ing binary equivalent.
Solution
2
0010
F
1111
9
1001
A
1010
So, (2F9A)16 = (0010111110011010)2
1.14 Digital Electronics, an easy approach to learn
Example 1.17 Convert the hexadecimal number (29B.2F)16 into its correspond-
ing octal equivalent.
Solution
2
0010
9
1001
B
1011
2
0010
F
1111
(29B.2F)16 = (001010011011.00101111)2
001
1
010
2
011
3
011
3
· 001
1
011
3
110
6
So, (29B.2F)16 = (1233.136)8
1.3 Complements
Complements are used in digital systems for simplifying the subtraction operation
and for logical manipulation. There are two types of complements for each base-b
system: radix complements and diminish radix complement.
Radix complement is referred to as the b’s complement and the diminished
radix complement is referred to as (b − 1)’s complement, where ‘b’ is the base or
radix of the number system.
For example, in decimal (base-10) system, two types of complements are pos-
sible: 10’s complements and 9’s complements.
Complements
Radix(b’s) Diminished radix (b-1)’s
Fig. 1.1 Types of complements
b’s complement of N can be found by, bn − N
where, b = base
n = number of digits in the number N
Similarly, (b − 1)’s complement of N can be found by, bn − N − 1
Note: After finding bn, it must be converted into base, b. (see the examples)
Number Systems 1.15
Example 1.18 Find the 10’s and 9’s complement of (786)10.
Solution
Here, b = 10; N = 786; n = 3.
∴ 10’s complement of (786)10 = bn
− N
= 103
− 786
= 214
And 9’s complement of (786)10 = bn
− N − 1
= 103
− 786 − 1
= 213
Note: (b − 1)’s complement can be found by subtracting 1 from b’s complement.
Similarly, b’s complement can be found by adding 1 to (b − 1)’s complement.
Example 1.19 Find the 1’s and 2’s complement of (101011)2.
Solution
Method - 1
Here, b = 2; N = 101011; n = 6.
∴ 2’s complement of (101011)2 = bn
− N
= (26
)2 − 101011
= 1000000 − 101011
= 010101
And 1’s complement of (101011)2 = bn
− N − 1
= (26
)2 − 101011 − 1
= 1000000 − 101011 − 1
= 010100
Trick:
Method - 2
For 1’s complement the result is obtained by complementing each binary bit that
is by replacing ‘1’ with ‘0’ and vice-versa.
1.16 Digital Electronics, an easy approach to learn
Hence, 1’s complement of (101011)2 = (010100)2.
For 2’s complement, the result is obtained by leaving all least significant zero’s
and first non-zero digit, unchanged from RHS and then replacing 1’s by 0’s and
0’s by 1’s in all the higher significant digits.
Hence, 2’s complement of (10101
complementing
higher bits
1)2 = (010101)2
Example 1.20 Find the 1’s and 2’s complements of (10110100)2.
Solution
1’s complement of (10110100)2 = (01001011)2
2’s complement of (10110 100
keep
unchanged
upto 1st
non - zero
bit
)2 = (01001100)2
1.4 Signed Binary Numbers
Positive integers are generally unsigned numbers but to represent a negative inte-
ger we need some kind of notation. In ordinary arithmetic, a negative number is
indicated by a minus sign and a positive number by a plus sign. While consider-
ing the case of computers, a lot of information is needed to be stored. But due to
hardware limitations the computers represent everything with binary digits.
The signed bit is the left most position of the number. The convention is
signed bit ‘0’ represents positive number and signed bit ‘1’ represents negative
number.
Binary numbers can be represented in three possible ways:
(i) Signed magnitude representation
(ii) Signed 1’s complement representation
(iii) Signed 2’s complement representation.
Signed magnitude representation
It is a representation in which, the MSB represents the sign of the number.
Number Systems 1.17
As for example, +3 −→ 0, 11
-3 −→ 1, 11
Note: The range of numbers that can be represented using signed magnitude rep-
resentation is −(2n−1 − 1) to (2n−1 − 1), where n is the integer.
Signed - 1’s complement representation
Here the positive binary number remains as it is and the negative binary number
is obtained by complementing all the bits including the sign bit.
For example, +7 −→ 0,111
-7 −→ 1,000
Note: The range of numbers that can be represented using signed 1’s complement
representation is −(2n−1 − 1) to (2n−1 − 1).
Signed - 2’s complement representation
Here the positive binary number remains as it is and the negative binary number is
obtained by taking the 2’s complement of the positive number including the sign
bit.
For example, +7 −→ 0,111
-7 −→ 1,001
Note: The range of numbers that can be represented using signed 2’s complement
representation is −2n−1 to (2n−1 − 1).
Table 1.1 Signed binary numbers
Decimal Signed magnitude Signed 1’s Signed 2’s
complement complement
+7 0,111 0,111 0,111
+6 0,110 0,110 0,110
+5 0,101 0,101 0,101
+4 0,100 0,100 0,100
+3 0,011 0,011 0,011
+2 0,010 0,010 0,010
+1 0,001 0,001 0,001
1.18 Digital Electronics, an easy approach to learn
Decimal Signed magnitude Signed 1’s Signed 2’s
complement complement
+0 0,000 0,000 0,000
-0 1,000 1,111 -
-1 1,001 1,110 1,111
-2 1,010 1,101 1,110
-3 1,011 1,100 1,101
-4 1,100 1,011 1,100
-5 1,101 1,010 1,011
-6 1,110 1,001 1,010
-7 1,111 1,000 1,001
Note:
• Positive numbers in all the three representations are identical and have zero
in the left most position.
• The signed 2’s complement system has only one representation for zero
(i.e., for +0 and -0, same representation is used).
1.5 Arithmetic Operations
The arithmetic operation includes addition, subtraction, multiplication and divi-
sion.
1.5.1 Binary arithmetic
Rules
Addition: Subtraction:
0 + 0 = 0 0 - 0 = 0
0 + 1 = 1 10 - 1 = 1
1 + 0 = 1 1 - 0 = 1
1 + 1 = 1 1 - 1 = 0
Multiplication: Division:
0 × 0 = 0 0 / 0 = not allowed
0 × 1 = 0 0 / 1 = 0
1 × 0 = 0 1 / 0 = not allowed
1 × 1 = 1 1 / 1 = 1
Number Systems 1.19
Binary addition
Two binary numbers can be added in the same way as two decimal numbers are
added.
For example,
10101 11
+ 11101 + 11
110010 110
∴ (10101)2 + (11101)2 = (110010)2;
(11)2 + (11)2 = (110)2
Binary subtraction
The binary subtraction is nothing but the addition of one binary number with a
negative (complemented) binary number.
Binary subtraction can be carried out in two ways -
Method 1 (using 1’s complement)
• Take 1’s complement of the number to be subtracted, as 1’s complement is
used to represent a negative number
• Add both the numbers
• If there is any overflow, then it is removed and added with the rest to obtain
the final result
• If the MSB, after addition is 1, then the final result is obtained by taking 1’s
complement of the addition, keeping the MSB as it is
Example 1.21 Subtract (1011)2 from (1110)2 using 1’s complement.
Solution
1110 =⇒ 1110 =⇒ 0010
- 1011 + 0100 + 1
1 ,0010 0011
So, (1110)2 − (1011)2 = (0011)2
Example 1.22 Subtract (1010)2 from (0110)2 using 1’s complement.
1.20 Digital Electronics, an easy approach to learn
Solution
0110 =⇒ 0110
- 1010 + 0101
1,011
↓
Here MSB is
1 without overflow
So, the result is 1,100(i.e. keeping MSB as it is and complementing the rest)
∴ (0110)2 − (1010)2 = (1, 100)2
Method 2 (using 2’s complement)
• Take 2’s complement of the number to be subtracted, as 2’s complement is
used to represent a negative number
• Add both the numbers
• If there is any overflow, then the overflow is simply removed and the result
is just the remaining
• If the MSB, after addition is 1, then the final result is obtained by taking 2’s
complement of the addition, keeping the MSB as it is
Example 1.23 Subtract (1011)2 from (1100)2 using 2’s complement.
Solution
1100 =⇒ 1100
- 1011 + 0101
1 ,0001
↓
Removed
So, (1100)2 − (1011)2 = (0, 001)2
Example 1.24 Subtract (1110)2 from (1001)2 using 2’s complement.
Solution
1001 =⇒ 1001
- 1110 + 0010
1,011
↓
Here MSB is
1 without overflow
Number Systems 1.21
So, the result is 1,101(i.e. keeping MSB as it is and 2’s complementing the rest)
(1001)2 − (1110)2 = (1, 101)2
Binary multiplication
Binary multiplication is similar to decimal multiplication.
Example 1.25 Multiply the binary numbers (1011)2 and (101)2.
Solution
1 0 1 1
× 1 0 1
1 0 1 1
0 0 0 0 X
1 0 1 1 X X
1 1 0 1 1 1
∴ The binary multiplication (1011)2 × (101)2 = (110111)2.
Binary division
Binary division also follows a similar procedure as decimal division.
Example 1.26 Divide (11011)2 by (101)2.
Solution
1.22 Digital Electronics, an easy approach to learn
Result = 101.01100
Hence, (11011)2 ÷ (101)2 = (101.01100)2
1.5.2 Octal arithmetic
As we know that octal system has radix or base 8, the maximum value of digit in
the octal system is 7. So, in this system we use the digits 0, 1, 2, 3,...., 6, 7.
Therefore, 7 + 1 = 8, as ‘8’ is not available in octal system.
Note: In decimal number systems, we take carry over for numbers ≥ 10 during
any arithmetic operation. Likewise, in octal number system we take carry over for
numbers ≥ 8.
Octal addition
Example 1.27 Add the octal numbers.
(i) (123)8 and (452)8.
(ii) (457)8 and (411)8.
Solution
(i) 123
+ 452
575
So (123)8 + (452)8 = (575)8
(ii) 457
+ 411
1070
So (457)8 + (411)8 = (1070)8
Octal subtraction
Example 1.28 Subtract the octal numbers.
(i) (765)8 and (234)8.
(ii) (751)8 and (254)8.
Number Systems 1.23
Solution
(i) 765
- 234
531
So (765)8 − (234)8 = (531)8
(ii) 751
- 254
475 (whenever we take a borrow, 8 is added to the digit and then the
required subtraction is carried out).
So (751)8 − (254)8 = (475)8
Octal multiplication
Example 1.29 Multiply the octal numbers.
(i) (23)8 and (12)8.
(ii) (56)8 and (45)8.
Solution
(i) 2 3
× 1 2
4 6
2 3
2 7 6
So (23)8 × (12)8 = (276)8
(ii) 5 6
× 4 5
3 4 6
2 7 0
3 2 4 6 (6 × 5 = 30. Subtract the maximum multiple of 8 from 30,
i.e. 8 × 3 = 24. So, 30 - 24 =6.
|
→ This 3 represents carry over
So (56)8 × (45)8 = (3246)8
1.24 Digital Electronics, an easy approach to learn
Octal division
Example 1.30 Divide the octal numbers.
(i) (24)8 and (2)8.
(ii) (127)8 and (6)8.
Solution
(i) 2)24(12
2
04
4
0
So (24)8 ÷ (2)8 = (12)8
(ii) 6) 127 (16.4
6
47
44
30
30
00
Hints:
(6)8 × (2)8 = (12)8
(6)8 × (2)8 = (14)8
(6)8 × (6)8 = (44)8
(6)8 × (4)8 = (30)8
So (127)8 ÷ (6)8 = (16.4)8
1.5.3 Hexadecimal arithmetic
Similar to octal arithmetic, hexadecimal arithmetic allows 16 different digits to
represent a hexadecimal number that is 0, 1, 2, 3, .......8, 9, A, B, C, D, E, F.
All the arithmetic operation procedures are similar to the decimal, octal sys-
tem etc .
Note: In hexadecimal system, we take carry over for numbers ≥ 16 during arith-
metic operation.
Hexadecimal addition
Example 1.31 Add the following Hexadecimal numbers.
(i) (21A)16 and (1B1)16.
(ii) (E75)16 and (68B)16.
Number Systems 1.25
Solution
(i) 2 1 A
+ 1 B 1
3 C B
So (21A)16 + (1B1)16 = (3CB)16
(ii) E 7 5
+ 6 8 B
1 5 0 0
So (E75)16 + (68B)16 = (1500)16
Hexadecimal subtraction
Example 1.32 Subtract the following hexadecimal numbers.
(i) (A68)16 and (837)16.
(ii) (C93)16 and (BD)16.
Solution
(i) A 6 8
− 8 3 7
2 3 1
So (A68)16 - (837)16 = (231)16
(ii) C 9 3
− B D
B D 6 (whenever we borrow, 16 is added to the digit).
So (C93)16 - (BD)16 = (BD6)16
Hexadecimal multiplication
Example 1.33 Multiply the following hexadecimal numbers.
(i) (23)16 and (46)16.
(ii) (45)16 and (B3)16.
1.26 Digital Electronics, an easy approach to learn
Solution
(i) 2 3
× 4 6
D 2
8 C
9 9 2
So (23)16 × (46)16 = (992)16
(ii) 4 5
× B 3
C F
2 F 7
3 0 3 F (B × 5 = 55. Subtract the maximum multiple of 16 from 55,
i.e. 16 × 3 = 48. So, 55 - 48 = 7.
Therefore, keeping 7, 3 is forwarded as carry.
So (45)16 × (B3)16 = (303F)16
Hexadecimal division
Example 1.34 Divide the hexadecimal numbers.
(i) (34)16 and (2)16.
(ii) (136)16 and (8)16.
Solution
(i) 2)34(1A
2
14
14
0
[ (2)16 × (A)16 = (14)16]
So (34)16 ÷ (2)16 = (1A)16
Number Systems 1.27
(ii) 8) 136 (26.C
10
36
30
60
60
00
Hints:
(8)16 × (2)16 = (16)16
(8)16 × (2)16 = (10)16
(8)16 × (6)16 = (30)16
(8)16 × (C)16 = (60)16
So (136)16 ÷ (8)16 = (26.C)16
1.6 Floating Point Representation
Floating point representation of numbers is generally used in a number system to
represent very large and very small numbers.
It consists of two parts:
• Signed fixed point number called mantissa (m).
• The position of the decimal (or radix) point, from which exponent (e) can
be derived.
The standard representation is, ±mantissa × baseexponent±mantissa × baseexponent
±mantissa × baseexponent
.
The base can be 2, 8, 10, 16 etc according to the number system used.
The mantissa as well as the exponent has a 0 in the leftmost position to denote
a plus (+) and 1 to denote a minus (-).
Consider the following decimal +27.198 = 27198 × 10−3
The above number in the floating point representation will look like,
0
sign
27198
mantissa
sign
1 ·03
exponent
.
The binary representation of this number is
0 110101000111110
mantissa
·1100111
exponent
1.28 Digital Electronics, an easy approach to learn
Brain teasers
1. Find out the minimum decimal equivalent of (111C.0).
Solution
Generally, one would solve the above question as
(1 × 163) + (1 × 162) + (1 × 161) + (C × 160)
But the minimum decimal equivalent can be obtained by looking at the
maximum value present in the question which is C = 12. So, we can
represent the above number in the question with base 13 (i.e. using 0 to 12
digits)
So, the minimum
decimal equivalent
= (1 × 133
) + (1 × 132
) + (1 × 131
) + (C × 130
)
= 2197 + 169 + 13 + 12
= 2391
2. Find out the number ‘X’ in the representation given below :
(257)8 + (1203)4 = (X)16(257)8 + (1203)4 = (X)16(257)8 + (1203)4 = (X)16
Solution
L.H.S in decimal equivalent is
= (2 × 82
) + (5 × 81
) + (7 × 80
) + (1 × 43
) + (2 × 42
)
+ (0 × 41
) + (3 × 40
)
= 128 + 40 + 7 + 64 + 32 + 0 + 3
= (274)10
Converting the above number into binary we get
(274)10 = (100010010)2 = (112)16
3. The solution to the quadratic equation :
x2 − 11x + 22 = 0x2 − 11x + 22 = 0x2 − 11x + 22 = 0
if x = 3x = 3x = 3 and x = 6x = 6x = 6; find out the base of the system?
Number Systems 1.29
Solution
Let base = b
x2
(1 × b0
) − x(1 × b1
+ 1 × b0
) + 2 × b1
+ 2 × b0
= 0
⇒ x2
− x(b + 1) + 2b + 2 = 0
Putting x = 3,
9 − 3(b + 1) + 2b + 2 = 0
⇒ b = 8
Putting x = 6,
36 − 6(b + 1) + 2b + 2 = 0
⇒ b = 8
So, base of the system is 8.
4. From the equation given below, find out the base of the number system:
√
41 = 5
√
41 = 5
√
41 = 5
Solution
⇒
√
41 = 5
⇒ 4(b) + 1(b0) = 5 × b0
⇒
√
4b + 1 = 5
⇒ 4b + 1 = 25
⇒ b = 6
So, base of the system is 6.
5. If (10001)2(10001)2(10001)2 is given in signed 2’s complement, what is the actual value?
Solution
Since, the signed bit is 1, it is a negative number.
Leaving the signed bit as it is, and taking the 2’s complement of the remain-
ing gives the magnitude of the actual number.
That is, 2’s complement of (0001)2 is (1111)2 = (15)10
So, the actual value in decimal number system is -15
1.30 Digital Electronics, an easy approach to learn
Objective Questions
1. One hex digit is sometimes referred to as a(n):
A. Byte
B. Nibble
C. Grouping
D. Instruction
2. How many binary digits are required to count to (100)10?
A. 7 B. 2 C. 3 D. 100
3. A binary number’s value changes most drastically when the is
changed.
A. MSB
B. Frequency
C. LSB
D. Duty cycle
4. Digital electronics is based on the numbering system.
A. Decimal
B. Octal
C. Binary
D. hexadecimal
5. An information signal that makes use of binary digits is considered to be:
A. Solid state
B. Digital
C. Analog
D. non-oscillating
6. The 1’s complement of 10011101 is .
A. 01100010
B. 10011110
C. 01100001
D. 01100011
7. Convert the decimal number 151.75 to binary.
A. 10000111.11
B. 11010011.01
C. 00111100.00
D. 10010111.11
8. The 2’s complement of 11100111 is .
A. 11100110
B. 00011001
C. 00011000
D. 00011010
Number Systems 1.31
9. Express the decimal number -37 as an 8-bit number in sign-magnitude.
A. 10100101
B. 00100101
C. 11011000
D. 11010001
10. Convert hexadecimal C0B to binary.
A. 110000001011
B. 110000001001
C. 110000001100
D. 110100001011
11. Convert binary 1001 to hexadecimal.
A. 916 B. 1116 C. 10116 D. 1016
12. Convert B516 hexadecimal number to decimal.
A. 212 B. 197 C. 165 D. 181
Answers for objectives
1. B 2. A 3. A 4. C 5. B 6. A
7. D 8. B 9. A 10. A 11. A 12. D
Exercises
1.1 Convert each binary number into its octal, decimal and hexadecimal equiv-
alent.
a) (1011)2
b) (110110)2
c) (1011.10)2
d) (110110.11010)2
1.2 Convert each decimal number into its equivalent binary, octal and hexadec-
imal equivalent.
a) (25)10
b) (375)10
c) (67.89)10
d) (138.657)10
1.3 Convert each octal number into its equivalent binary, decimal and hexadec-
imal equivalent.
a) (37)8 b) (62)8 c) (23.12)8 d) (54.623)8
1.32 Digital Electronics, an easy approach to learn
1.4 Convert each hexadecimal number into its equivalent binary, octal and dec-
imal equivalent.
a) (19)16
b) (AF)16
c) (C1.56)16
d) (BCD.12)16
1.5 Add, subtract, multiply and divide the following binary numbers:
a) 1011 and 101 b) 11110 and 1011
1.6 Add, subtract, multiply and divide the following octal numbers:
a) 47 and 21 b) 323 and 56
1.7 Add, subtract, multiply and divide the following hexadecimal numbers:
a) FB3 and 23 b) B789 and EC
1.8 Find the 1’s and 2’s complements of the following:
a) 1011 b) 1000110 c) 1100011
1.9 Find the 9’s and 10’s complement of the following numbers:
a) 563 b) 24 c) 1079
Answers for exercises
1.1 a) 13, 11, B
b) 66, 54, 36
c) 13.4, 11.5, B.8
d) 66.64, 54.81249, 36.D
Number Systems 1.33
1.2 a) 11001, 31, 19
b) 101110111, 567, 177
c) 10001010.1110001111...., 103.7075....., 43.E3D7....
d) 10001010.101010000....., 212.5203......, 8A.A831....
1.3 a) 11111, 31, 1F
b) 110010, 50, 32
c) 10011.00101, 19.156249, 13.28
d) 101100.110010011, 44.78710...., 2C.C98
1.4 a) 11001, 31, 25
b) 10101111, 257, 175
c) 11000001.0101011, 301.254, 193.3359.....
d) 101111001101.0001001, 5715.044, 3021.07031.....
1.5 a) 10000, 110, 110111, 10.0011
b) 101001, 10011, 101001010, 10.10111....
1.6 a) 70, 26, 1227, 2.226455.....
b) 401, 245, 22752, 4.4544....
1.7 a) FD6, F90, 22579, 72.D41
b) B875, B69D, A9324C, C7.16C7....
1.8 a) 0100, 0101
b) 0111001, 0111010
c) 0011100, 0011101
1.9 a) 436, 437
b) 75, 76
c) 8920, 8921
Chapter   1

Chapter 1

  • 1.
    Number Systems Chapter 1 1.1 Introduction Adigital system is a combination of devices designed to manipulate physical quantities or information that are represented in digital form, that, is they can only take discrete values. A digital system includes digital computers, calculators, telephone system and digital audio and video equipment. Advantages of digital techniques over analog • Easier to design • Generally the information is stored in the form of 1’s and 0’s, hence easier to store any data. • Digital circuits are less affected by noise as noise is analog in nature. • Processing and reprogramming is possible in digital circuits. • Power dissipation is less. • Less bulky and less cost. FACT: World’s largest known digital system is telephone system. Limitation of digital technique • Real world is mainly analog. So, digital data needs to be converted into analog form for human understanding.
  • 2.
    1.2 Digital Electronics,an easy approach to learn 1.2 Number Systems Number systems are introduced mainly to quantify the magnitude of something. So we can say that number system gradually evolved with the concept of counting. There are many number systems out of which the most frequently used are: • Decimal number system • Binary number system • Octal number system and • Hexadecimal number system. FACT: We generally use decimal number system in our day-to-day life. A number (N)b is represented as, (N)b = dn−1dn−2dn−3....d1d0 integral portion · radix point d−1d−2d−3....d−m fractional portion Where, N = number b = base or radix d = different symbols used in the number system n = number of digits in the left side of the radix point m = number of digits in the right side of the radix point Radix is defined as the number of different symbols used in a particular num- ber system. For example, in decimal number system, the base is 10. So, we use 10 different symbols (digits) 0, 1, 2, 3, 4....8, 9 to represent any decimal number. Note: The maximum value of digit in any number system is given by (b − 1). For example, maximum value of digit in decimal number system = (10 -1) = 9 Any number system can be converted into decimal number system by using the following formula: Decimal equivalent = dn−1(b)n−1 + dn−2(b)n−2 + ...... + d1(b)1 + d0(b)0+ d−1(b)−1 + d−2(b)−2 + ........ + d−m(b)−m 1.2.1 Binary number system It is a simple number system as it consists of only 2 digits (symbols), 0 and 1. Hence, it is called as base-2 number system or binary number system. For example, (1011101)2, (101011.101)2, etc.
  • 3.
    Number Systems 1.3 Decimal- binary conversion Conversion of decimal number to binary number A decimal number can be easily converted into binary number by dividing the decimal number by 2 progressively, until the quotient of zero is obtained. The bi- nary number is obtained by taking the remainder after each division in the reverse order. The examples discussed below will best describe the conversion. Example 1.1 Convert the decimal number (23)10 into its equivalent binary num- ber. Solution Taking the remainders from bottom to top, the equivalent binary number can be written as (10111)2. Example 1.2 Convert the decimal number (18.125)10 into its equivalent binary number. Solution The integral part and the fractional part are computed separately. Integral conversion: 2 2 2 2 18 9 4 2 1 - - - - 0 0 1 0 Top Bottom (18)10 = (10010)2 Fractional conversion: If the decimal number contains a fractional part, then its binary equivalent is ob- tained by multiplying the fractional part continuously by 2, removing the carry
  • 4.
    1.4 Digital Electronics,an easy approach to learn over (whether 0 or 1) in the integer position each time. The removed carry over in forward order gives the required binary number. 0.125 0.250 0.500 × 2 × 2 × 2 1.000 Forward order (0.125)10 = (0.001)2 Hence, (18.125)10 = (10010.001)2 Example 1.3 Convert the decimal number (12.1)10 into its binary equivalent. Solution Integral conversion: 2 2 2 12 6 3 1 - - - 1 0 0 Top Bottom Fractional conversion: 0.1 0.2 0.4 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 0.8 1.6 1.2 0.4 0.8 1.6 1.2 Forward order
  • 5.
    Number Systems 1.5 Hence, (12.1)10= (1100.000110011....)2 = (1100.00011)2 Conversion of binary to decimal number We know that any number system can be converted into decimal number system by using the formula: Decimal equivalent = dn−1(b)n−1 + dn−2(b)n−2 + ...... + d1(b)1 + d0(b)0+ d−1(b)−1+d−2(b)−2+........+d−m(b)−m Example 1.4 Convert the binary number (10110)2 into its decimal equivalent. Solution Base, b = 2 n = number of digits = 5 Hence by using the formula, Decimal equivalent = (1 × 24 ) + (0 × 23 ) + (1 × 22 ) + (1 × 21 ) + (0 × 20 ) = 16 + 0 + 4 + 2 + 0 = 22 So, (10110)2 = (22)10 Example 1.5 Convert the binary number (111001)2 into its decimal equivalent. Solution Base, b = 2 n = number of digits = 6 Hence by using the formula, Decimal equivalent = (1 × 25 ) + (1 × 24 ) + (1 × 23 ) + (0 × 22 ) + (0 × 21 ) + (1 × 20 ) = 32 + 16 + 8 + 0 + 0 + 1 = 57 So, (111001)2 = (57)10
  • 6.
    1.6 Digital Electronics,an easy approach to learn Example 1.6 Convert the binary number (10000.1011)2 into its decimal equiv- alent. Solution Base, b = 2 n = number of digits = 5 (considering only integral part) Hence by using the formula, Decimal equivalent = (1 × 24 ) + (0 × 23 ) + (0 × 22 ) + (0 × 21 ) + (0 × 20 ) + (1 × 2−1 ) + (0 × 2−2 ) + (1 × 2−3 ) + (1 × 2−4 ) = 16 + 0 + 0 + 0 + 0 + 0.5 + 0 + 0.125 + 0.0625 = 16.6875 So, (10000.1011)2 = (16.6875)10 2 Concept: Any decimal number can be converted to any other number system by dividing the decimal number by the base of the other number system progressively, until the quotient of zero is obtained and taking the remainder after each division in reverse order. For example, while converting decimal to binary, we divide the decimal number pro- gressively by 2. 1.2.2 Octal number system The octal number system uses 8 different symbols 0, 1, 2, 3....6, 7. Its base is 8. Octal - decimal conversion Conversion of decimal to octal It is similar to decimal to binary conversion. For integral decimal, the number is repeatedly divided by 8 and for fraction, the number is multiplied by 8. Example 1.7 Convert the decimal number (78)10 into its equivalent octal num- ber. Solution 8 8 78 9 1 - - 1 6 Top Bottom
  • 7.
    Number Systems 1.7 Takingthe remainders from bottom to top, the equivalent octal number can be written as (116)8. Example 1.8 Convert the decimal number (321.456)10 into its equivalent octal number. Solution The integral part and the fractional part are computed separately. Integral conversion: 8 8 321 40 5 - - 0 1 Top Bottom Fractional conversion: Terminate the process after 5-6 multiplications (More number of multiplications increases the accuracy of the answer) Hence, (321.456)10 = (501.3513615)8 Conversion of octal to decimal Example 1.9 Convert the octal number (6327.4051)8 into its decimal equiva- lent. Solution We know that any number system can be converted to decimal number system by using the formula:
  • 8.
    1.8 Digital Electronics,an easy approach to learn Decimal equivalent = dn−1(b)n−1 + dn−2(b)n−2 + ...... + d1(b)1 + d0(b)0+ d−1(b)−1+d−2(b)−2+........+d−m(b)−m Here, Base, b = 8 n = number of digits = 4(consider only integral part) Hence by using the formula, Decimal equivalent = (6 × 83 ) + (3 × 82 ) + (2 × 81 ) + (7 × 80 ) + (4 × 8−1 ) + (0 × 8−2 ) + (5 × 8−3 ) + (1 × 8−4 ) = 3072 + 192 + 16 + 7 + 4 8 + 0 + 5 512 + 1 4096 = 3287.510098 So, (6327.4051)8 = (3287.5100098)10 1.2.3 Hexadecimal number system The hexadecimal number system has a base of 16 and uses 16 different symbols, namely (0, 1, 2, 3, 4.....8, 9, A, B, C, D, E, F). Where, A = 10 B = 11 C = 12 D = 13 E = 14 F = 15 FACT: Microprocessor deals with instruction and data that uses hexadecimal number sys- tem, for programming purposes. Since this system contains both numeric digits and alphabets, this is called as alphanumeric number system. Hexadecimal - decimal conversion Conversion of decimal to hexadecimal It is similar to decimal-binary conversion. For integral part, the decimal num- ber is repeatedly divided by 16 and for fractional part, the number is repeatedly multiplied by 16.
  • 9.
    Number Systems 1.9 Example1.10 Convert the decimal number (156.625)10 into its equivalent hex- adecimal number system. Solution The integral part and the fractional part are computed separately. Integral conversion: 16 156 9 - C Top Bottom Fractional conversion: 0.625 A.000 × 16Forward order Hence, (156.625)10 = (9C.A)16 Conversion of hexadecimal to decimal Example 1.11 Convert (3DB)16 into decimal equivalent. Solution n = 3; b = 16 Decimal equivalent = (3 × 162 ) + (D × 161 ) + (B × 160 ) = (3 × 162 ) + (13 × 161 ) + (11 × 160 ) = 768 + 208 + 11 = 987 So, (3DB)16 = (987)10 Conversion between octal - hexadecimal - binary - decimal Example 1.12 Convert (189)10 into its equivalent octal, hexadecimal and bi- nary forms.
  • 10.
    1.10 Digital Electronics,an easy approach to learn Solution Binary conversion: So, (189)10 = (10111101)2 Octal conversion: 8 8 189 23 2 - - 7 5 Top Bottom So, (189)10 = (275)8 Hexadecimal conversion: 16 189 11 - 13 Top Bottom So, (189)10 = (BD)16 Example 1.13 Convert (110111001)2 into its equivalent base 8, base 10, and base 16 number system. Solution Octal conversion: There are two methods of binary to octal conversion. Method 1: Convert the binary number into its decimal equivalent and then convert the deci- mal into octal.
  • 11.
    Number Systems 1.11 (110111001)2; Here,n = 9, b = 2 Decimal equivalent = (1 × 28 ) + (1 × 27 ) + (0 × 26 ) + (1 × 25 ) + (1 × 24 ) + (1 × 23 ) + (0 × 22 ) + (0 × 21 ) + (1 × 20 ) = 441 Now, (441)10 can be converted into octal 8 8 441 55 6 - - 7 1 Top Bottom So, (110111001)2 = (441)10 = (671)8 Method - 2 2 Concept: Octal has base 8 i.e. 23 . So, make a grouping of 3 binary bits from right hand side in order to obtain the corresponding octal number. (110 111 001)2 6 7 1 Hence, (110111001)2 = (671)8. Hexadecimal conversion: A binary number can also be converted into hexadecimal in 2 ways as stated above for octal conversion. Method 1: Convert the binary number into its decimal equivalent and then convert the deci- mal into hexadecimal. (110111001)2; n = 9, b = 2 Decimal equivalent = (1 × 28 ) + (1 × 27 ) + (0 × 26 ) + (1 × 25 ) + (1 × 24 ) + (1 × 23 ) + (0 × 22 ) + (0 × 21 ) + (1 × 20 ) = 441 Now, (441)10 can be converted into hexadecimal
  • 12.
    1.12 Digital Electronics,an easy approach to learn 16 16 441 27 1 - - 11 9 Top Bottom So, (110111001)2 = (441)10 = (1B9)16 Method - 2 2 Concept: Hexadecimal has a base 16 i.e. 24 . So, make a grouping of 4 binary bits from right hand side inorder to obtain the corresponding hexadecimal equivalent for a given binary number representation. (110111001)2 = (0001 1011 1001)2 1 B 9 Hence, (110111001)2 = (1B9)16. Example 1.14 Convert the octal number (172)8 into its corresponding binary, decimal and hexadecimal equivalent. Solution Binary conversion: (1 7 2)8 ↓ 001 111 010 So, (172)8 = (001111010)2 Decimal conversion: n = 3, b = 8 Decimal equivalent = (1 × 82 ) + (7 × 81 ) + (2 × 80 ) = 64 + 56 + 2 = 122 So, (172)8 = (122)10 Hexadecimal conversion: 2 Concept: For conversion of octal to hexadecimal or hexadecimal to octal number system, we need another number system like binary or decimal number system as an intermediary number system in conversion. Taking binary number system as the inter- mediary is easier.
  • 13.
    Number Systems 1.13 Method- 1 Octal −→ decimal −→ hexadecimal Method - 2 (easier) Octal −→ binary −→ hexadecimal From method - 2 (1 7 2)8 = (001111010)2 ↓ 001 111 010 (001 111 010)2 = (0000 0 0111 7 1010 A )2 So, (172)8 = (07A)16 Example 1.15 Convert the binary number (1011011110.11001010011)2 into its corresponding octal equivalent. Solution For left side of the radix point we group the bit from LSB (Least Significant Bit), and if needed, we append additional 0 in the left most side, (MSB) ←− 001 1 011 3 011 3 110 6 −→ (LSB) For right side of the radix point we group the bit from MSB (Most Significant Bit), and if needed, we append additional 0 in the right most side, (MSB) ←− 110 6 010 2 100 4 110 6 −→ (LSB) So, (1011011110.11001010011)2 = (1336.6246)8 Example 1.16 Convert the hexadecimal number (2F9A)16 into its correspond- ing binary equivalent. Solution 2 0010 F 1111 9 1001 A 1010 So, (2F9A)16 = (0010111110011010)2
  • 14.
    1.14 Digital Electronics,an easy approach to learn Example 1.17 Convert the hexadecimal number (29B.2F)16 into its correspond- ing octal equivalent. Solution 2 0010 9 1001 B 1011 2 0010 F 1111 (29B.2F)16 = (001010011011.00101111)2 001 1 010 2 011 3 011 3 · 001 1 011 3 110 6 So, (29B.2F)16 = (1233.136)8 1.3 Complements Complements are used in digital systems for simplifying the subtraction operation and for logical manipulation. There are two types of complements for each base-b system: radix complements and diminish radix complement. Radix complement is referred to as the b’s complement and the diminished radix complement is referred to as (b − 1)’s complement, where ‘b’ is the base or radix of the number system. For example, in decimal (base-10) system, two types of complements are pos- sible: 10’s complements and 9’s complements. Complements Radix(b’s) Diminished radix (b-1)’s Fig. 1.1 Types of complements b’s complement of N can be found by, bn − N where, b = base n = number of digits in the number N Similarly, (b − 1)’s complement of N can be found by, bn − N − 1 Note: After finding bn, it must be converted into base, b. (see the examples)
  • 15.
    Number Systems 1.15 Example1.18 Find the 10’s and 9’s complement of (786)10. Solution Here, b = 10; N = 786; n = 3. ∴ 10’s complement of (786)10 = bn − N = 103 − 786 = 214 And 9’s complement of (786)10 = bn − N − 1 = 103 − 786 − 1 = 213 Note: (b − 1)’s complement can be found by subtracting 1 from b’s complement. Similarly, b’s complement can be found by adding 1 to (b − 1)’s complement. Example 1.19 Find the 1’s and 2’s complement of (101011)2. Solution Method - 1 Here, b = 2; N = 101011; n = 6. ∴ 2’s complement of (101011)2 = bn − N = (26 )2 − 101011 = 1000000 − 101011 = 010101 And 1’s complement of (101011)2 = bn − N − 1 = (26 )2 − 101011 − 1 = 1000000 − 101011 − 1 = 010100 Trick: Method - 2 For 1’s complement the result is obtained by complementing each binary bit that is by replacing ‘1’ with ‘0’ and vice-versa.
  • 16.
    1.16 Digital Electronics,an easy approach to learn Hence, 1’s complement of (101011)2 = (010100)2. For 2’s complement, the result is obtained by leaving all least significant zero’s and first non-zero digit, unchanged from RHS and then replacing 1’s by 0’s and 0’s by 1’s in all the higher significant digits. Hence, 2’s complement of (10101 complementing higher bits 1)2 = (010101)2 Example 1.20 Find the 1’s and 2’s complements of (10110100)2. Solution 1’s complement of (10110100)2 = (01001011)2 2’s complement of (10110 100 keep unchanged upto 1st non - zero bit )2 = (01001100)2 1.4 Signed Binary Numbers Positive integers are generally unsigned numbers but to represent a negative inte- ger we need some kind of notation. In ordinary arithmetic, a negative number is indicated by a minus sign and a positive number by a plus sign. While consider- ing the case of computers, a lot of information is needed to be stored. But due to hardware limitations the computers represent everything with binary digits. The signed bit is the left most position of the number. The convention is signed bit ‘0’ represents positive number and signed bit ‘1’ represents negative number. Binary numbers can be represented in three possible ways: (i) Signed magnitude representation (ii) Signed 1’s complement representation (iii) Signed 2’s complement representation. Signed magnitude representation It is a representation in which, the MSB represents the sign of the number.
  • 17.
    Number Systems 1.17 Asfor example, +3 −→ 0, 11 -3 −→ 1, 11 Note: The range of numbers that can be represented using signed magnitude rep- resentation is −(2n−1 − 1) to (2n−1 − 1), where n is the integer. Signed - 1’s complement representation Here the positive binary number remains as it is and the negative binary number is obtained by complementing all the bits including the sign bit. For example, +7 −→ 0,111 -7 −→ 1,000 Note: The range of numbers that can be represented using signed 1’s complement representation is −(2n−1 − 1) to (2n−1 − 1). Signed - 2’s complement representation Here the positive binary number remains as it is and the negative binary number is obtained by taking the 2’s complement of the positive number including the sign bit. For example, +7 −→ 0,111 -7 −→ 1,001 Note: The range of numbers that can be represented using signed 2’s complement representation is −2n−1 to (2n−1 − 1). Table 1.1 Signed binary numbers Decimal Signed magnitude Signed 1’s Signed 2’s complement complement +7 0,111 0,111 0,111 +6 0,110 0,110 0,110 +5 0,101 0,101 0,101 +4 0,100 0,100 0,100 +3 0,011 0,011 0,011 +2 0,010 0,010 0,010 +1 0,001 0,001 0,001
  • 18.
    1.18 Digital Electronics,an easy approach to learn Decimal Signed magnitude Signed 1’s Signed 2’s complement complement +0 0,000 0,000 0,000 -0 1,000 1,111 - -1 1,001 1,110 1,111 -2 1,010 1,101 1,110 -3 1,011 1,100 1,101 -4 1,100 1,011 1,100 -5 1,101 1,010 1,011 -6 1,110 1,001 1,010 -7 1,111 1,000 1,001 Note: • Positive numbers in all the three representations are identical and have zero in the left most position. • The signed 2’s complement system has only one representation for zero (i.e., for +0 and -0, same representation is used). 1.5 Arithmetic Operations The arithmetic operation includes addition, subtraction, multiplication and divi- sion. 1.5.1 Binary arithmetic Rules Addition: Subtraction: 0 + 0 = 0 0 - 0 = 0 0 + 1 = 1 10 - 1 = 1 1 + 0 = 1 1 - 0 = 1 1 + 1 = 1 1 - 1 = 0 Multiplication: Division: 0 × 0 = 0 0 / 0 = not allowed 0 × 1 = 0 0 / 1 = 0 1 × 0 = 0 1 / 0 = not allowed 1 × 1 = 1 1 / 1 = 1
  • 19.
    Number Systems 1.19 Binaryaddition Two binary numbers can be added in the same way as two decimal numbers are added. For example, 10101 11 + 11101 + 11 110010 110 ∴ (10101)2 + (11101)2 = (110010)2; (11)2 + (11)2 = (110)2 Binary subtraction The binary subtraction is nothing but the addition of one binary number with a negative (complemented) binary number. Binary subtraction can be carried out in two ways - Method 1 (using 1’s complement) • Take 1’s complement of the number to be subtracted, as 1’s complement is used to represent a negative number • Add both the numbers • If there is any overflow, then it is removed and added with the rest to obtain the final result • If the MSB, after addition is 1, then the final result is obtained by taking 1’s complement of the addition, keeping the MSB as it is Example 1.21 Subtract (1011)2 from (1110)2 using 1’s complement. Solution 1110 =⇒ 1110 =⇒ 0010 - 1011 + 0100 + 1 1 ,0010 0011 So, (1110)2 − (1011)2 = (0011)2 Example 1.22 Subtract (1010)2 from (0110)2 using 1’s complement.
  • 20.
    1.20 Digital Electronics,an easy approach to learn Solution 0110 =⇒ 0110 - 1010 + 0101 1,011 ↓ Here MSB is 1 without overflow So, the result is 1,100(i.e. keeping MSB as it is and complementing the rest) ∴ (0110)2 − (1010)2 = (1, 100)2 Method 2 (using 2’s complement) • Take 2’s complement of the number to be subtracted, as 2’s complement is used to represent a negative number • Add both the numbers • If there is any overflow, then the overflow is simply removed and the result is just the remaining • If the MSB, after addition is 1, then the final result is obtained by taking 2’s complement of the addition, keeping the MSB as it is Example 1.23 Subtract (1011)2 from (1100)2 using 2’s complement. Solution 1100 =⇒ 1100 - 1011 + 0101 1 ,0001 ↓ Removed So, (1100)2 − (1011)2 = (0, 001)2 Example 1.24 Subtract (1110)2 from (1001)2 using 2’s complement. Solution 1001 =⇒ 1001 - 1110 + 0010 1,011 ↓ Here MSB is 1 without overflow
  • 21.
    Number Systems 1.21 So,the result is 1,101(i.e. keeping MSB as it is and 2’s complementing the rest) (1001)2 − (1110)2 = (1, 101)2 Binary multiplication Binary multiplication is similar to decimal multiplication. Example 1.25 Multiply the binary numbers (1011)2 and (101)2. Solution 1 0 1 1 × 1 0 1 1 0 1 1 0 0 0 0 X 1 0 1 1 X X 1 1 0 1 1 1 ∴ The binary multiplication (1011)2 × (101)2 = (110111)2. Binary division Binary division also follows a similar procedure as decimal division. Example 1.26 Divide (11011)2 by (101)2. Solution
  • 22.
    1.22 Digital Electronics,an easy approach to learn Result = 101.01100 Hence, (11011)2 ÷ (101)2 = (101.01100)2 1.5.2 Octal arithmetic As we know that octal system has radix or base 8, the maximum value of digit in the octal system is 7. So, in this system we use the digits 0, 1, 2, 3,...., 6, 7. Therefore, 7 + 1 = 8, as ‘8’ is not available in octal system. Note: In decimal number systems, we take carry over for numbers ≥ 10 during any arithmetic operation. Likewise, in octal number system we take carry over for numbers ≥ 8. Octal addition Example 1.27 Add the octal numbers. (i) (123)8 and (452)8. (ii) (457)8 and (411)8. Solution (i) 123 + 452 575 So (123)8 + (452)8 = (575)8 (ii) 457 + 411 1070 So (457)8 + (411)8 = (1070)8 Octal subtraction Example 1.28 Subtract the octal numbers. (i) (765)8 and (234)8. (ii) (751)8 and (254)8.
  • 23.
    Number Systems 1.23 Solution (i)765 - 234 531 So (765)8 − (234)8 = (531)8 (ii) 751 - 254 475 (whenever we take a borrow, 8 is added to the digit and then the required subtraction is carried out). So (751)8 − (254)8 = (475)8 Octal multiplication Example 1.29 Multiply the octal numbers. (i) (23)8 and (12)8. (ii) (56)8 and (45)8. Solution (i) 2 3 × 1 2 4 6 2 3 2 7 6 So (23)8 × (12)8 = (276)8 (ii) 5 6 × 4 5 3 4 6 2 7 0 3 2 4 6 (6 × 5 = 30. Subtract the maximum multiple of 8 from 30, i.e. 8 × 3 = 24. So, 30 - 24 =6. | → This 3 represents carry over So (56)8 × (45)8 = (3246)8
  • 24.
    1.24 Digital Electronics,an easy approach to learn Octal division Example 1.30 Divide the octal numbers. (i) (24)8 and (2)8. (ii) (127)8 and (6)8. Solution (i) 2)24(12 2 04 4 0 So (24)8 ÷ (2)8 = (12)8 (ii) 6) 127 (16.4 6 47 44 30 30 00 Hints: (6)8 × (2)8 = (12)8 (6)8 × (2)8 = (14)8 (6)8 × (6)8 = (44)8 (6)8 × (4)8 = (30)8 So (127)8 ÷ (6)8 = (16.4)8 1.5.3 Hexadecimal arithmetic Similar to octal arithmetic, hexadecimal arithmetic allows 16 different digits to represent a hexadecimal number that is 0, 1, 2, 3, .......8, 9, A, B, C, D, E, F. All the arithmetic operation procedures are similar to the decimal, octal sys- tem etc . Note: In hexadecimal system, we take carry over for numbers ≥ 16 during arith- metic operation. Hexadecimal addition Example 1.31 Add the following Hexadecimal numbers. (i) (21A)16 and (1B1)16. (ii) (E75)16 and (68B)16.
  • 25.
    Number Systems 1.25 Solution (i)2 1 A + 1 B 1 3 C B So (21A)16 + (1B1)16 = (3CB)16 (ii) E 7 5 + 6 8 B 1 5 0 0 So (E75)16 + (68B)16 = (1500)16 Hexadecimal subtraction Example 1.32 Subtract the following hexadecimal numbers. (i) (A68)16 and (837)16. (ii) (C93)16 and (BD)16. Solution (i) A 6 8 − 8 3 7 2 3 1 So (A68)16 - (837)16 = (231)16 (ii) C 9 3 − B D B D 6 (whenever we borrow, 16 is added to the digit). So (C93)16 - (BD)16 = (BD6)16 Hexadecimal multiplication Example 1.33 Multiply the following hexadecimal numbers. (i) (23)16 and (46)16. (ii) (45)16 and (B3)16.
  • 26.
    1.26 Digital Electronics,an easy approach to learn Solution (i) 2 3 × 4 6 D 2 8 C 9 9 2 So (23)16 × (46)16 = (992)16 (ii) 4 5 × B 3 C F 2 F 7 3 0 3 F (B × 5 = 55. Subtract the maximum multiple of 16 from 55, i.e. 16 × 3 = 48. So, 55 - 48 = 7. Therefore, keeping 7, 3 is forwarded as carry. So (45)16 × (B3)16 = (303F)16 Hexadecimal division Example 1.34 Divide the hexadecimal numbers. (i) (34)16 and (2)16. (ii) (136)16 and (8)16. Solution (i) 2)34(1A 2 14 14 0 [ (2)16 × (A)16 = (14)16] So (34)16 ÷ (2)16 = (1A)16
  • 27.
    Number Systems 1.27 (ii)8) 136 (26.C 10 36 30 60 60 00 Hints: (8)16 × (2)16 = (16)16 (8)16 × (2)16 = (10)16 (8)16 × (6)16 = (30)16 (8)16 × (C)16 = (60)16 So (136)16 ÷ (8)16 = (26.C)16 1.6 Floating Point Representation Floating point representation of numbers is generally used in a number system to represent very large and very small numbers. It consists of two parts: • Signed fixed point number called mantissa (m). • The position of the decimal (or radix) point, from which exponent (e) can be derived. The standard representation is, ±mantissa × baseexponent±mantissa × baseexponent ±mantissa × baseexponent . The base can be 2, 8, 10, 16 etc according to the number system used. The mantissa as well as the exponent has a 0 in the leftmost position to denote a plus (+) and 1 to denote a minus (-). Consider the following decimal +27.198 = 27198 × 10−3 The above number in the floating point representation will look like, 0 sign 27198 mantissa sign 1 ·03 exponent . The binary representation of this number is 0 110101000111110 mantissa ·1100111 exponent
  • 28.
    1.28 Digital Electronics,an easy approach to learn Brain teasers 1. Find out the minimum decimal equivalent of (111C.0). Solution Generally, one would solve the above question as (1 × 163) + (1 × 162) + (1 × 161) + (C × 160) But the minimum decimal equivalent can be obtained by looking at the maximum value present in the question which is C = 12. So, we can represent the above number in the question with base 13 (i.e. using 0 to 12 digits) So, the minimum decimal equivalent = (1 × 133 ) + (1 × 132 ) + (1 × 131 ) + (C × 130 ) = 2197 + 169 + 13 + 12 = 2391 2. Find out the number ‘X’ in the representation given below : (257)8 + (1203)4 = (X)16(257)8 + (1203)4 = (X)16(257)8 + (1203)4 = (X)16 Solution L.H.S in decimal equivalent is = (2 × 82 ) + (5 × 81 ) + (7 × 80 ) + (1 × 43 ) + (2 × 42 ) + (0 × 41 ) + (3 × 40 ) = 128 + 40 + 7 + 64 + 32 + 0 + 3 = (274)10 Converting the above number into binary we get (274)10 = (100010010)2 = (112)16 3. The solution to the quadratic equation : x2 − 11x + 22 = 0x2 − 11x + 22 = 0x2 − 11x + 22 = 0 if x = 3x = 3x = 3 and x = 6x = 6x = 6; find out the base of the system?
  • 29.
    Number Systems 1.29 Solution Letbase = b x2 (1 × b0 ) − x(1 × b1 + 1 × b0 ) + 2 × b1 + 2 × b0 = 0 ⇒ x2 − x(b + 1) + 2b + 2 = 0 Putting x = 3, 9 − 3(b + 1) + 2b + 2 = 0 ⇒ b = 8 Putting x = 6, 36 − 6(b + 1) + 2b + 2 = 0 ⇒ b = 8 So, base of the system is 8. 4. From the equation given below, find out the base of the number system: √ 41 = 5 √ 41 = 5 √ 41 = 5 Solution ⇒ √ 41 = 5 ⇒ 4(b) + 1(b0) = 5 × b0 ⇒ √ 4b + 1 = 5 ⇒ 4b + 1 = 25 ⇒ b = 6 So, base of the system is 6. 5. If (10001)2(10001)2(10001)2 is given in signed 2’s complement, what is the actual value? Solution Since, the signed bit is 1, it is a negative number. Leaving the signed bit as it is, and taking the 2’s complement of the remain- ing gives the magnitude of the actual number. That is, 2’s complement of (0001)2 is (1111)2 = (15)10 So, the actual value in decimal number system is -15
  • 30.
    1.30 Digital Electronics,an easy approach to learn Objective Questions 1. One hex digit is sometimes referred to as a(n): A. Byte B. Nibble C. Grouping D. Instruction 2. How many binary digits are required to count to (100)10? A. 7 B. 2 C. 3 D. 100 3. A binary number’s value changes most drastically when the is changed. A. MSB B. Frequency C. LSB D. Duty cycle 4. Digital electronics is based on the numbering system. A. Decimal B. Octal C. Binary D. hexadecimal 5. An information signal that makes use of binary digits is considered to be: A. Solid state B. Digital C. Analog D. non-oscillating 6. The 1’s complement of 10011101 is . A. 01100010 B. 10011110 C. 01100001 D. 01100011 7. Convert the decimal number 151.75 to binary. A. 10000111.11 B. 11010011.01 C. 00111100.00 D. 10010111.11 8. The 2’s complement of 11100111 is . A. 11100110 B. 00011001 C. 00011000 D. 00011010
  • 31.
    Number Systems 1.31 9.Express the decimal number -37 as an 8-bit number in sign-magnitude. A. 10100101 B. 00100101 C. 11011000 D. 11010001 10. Convert hexadecimal C0B to binary. A. 110000001011 B. 110000001001 C. 110000001100 D. 110100001011 11. Convert binary 1001 to hexadecimal. A. 916 B. 1116 C. 10116 D. 1016 12. Convert B516 hexadecimal number to decimal. A. 212 B. 197 C. 165 D. 181 Answers for objectives 1. B 2. A 3. A 4. C 5. B 6. A 7. D 8. B 9. A 10. A 11. A 12. D Exercises 1.1 Convert each binary number into its octal, decimal and hexadecimal equiv- alent. a) (1011)2 b) (110110)2 c) (1011.10)2 d) (110110.11010)2 1.2 Convert each decimal number into its equivalent binary, octal and hexadec- imal equivalent. a) (25)10 b) (375)10 c) (67.89)10 d) (138.657)10 1.3 Convert each octal number into its equivalent binary, decimal and hexadec- imal equivalent. a) (37)8 b) (62)8 c) (23.12)8 d) (54.623)8
  • 32.
    1.32 Digital Electronics,an easy approach to learn 1.4 Convert each hexadecimal number into its equivalent binary, octal and dec- imal equivalent. a) (19)16 b) (AF)16 c) (C1.56)16 d) (BCD.12)16 1.5 Add, subtract, multiply and divide the following binary numbers: a) 1011 and 101 b) 11110 and 1011 1.6 Add, subtract, multiply and divide the following octal numbers: a) 47 and 21 b) 323 and 56 1.7 Add, subtract, multiply and divide the following hexadecimal numbers: a) FB3 and 23 b) B789 and EC 1.8 Find the 1’s and 2’s complements of the following: a) 1011 b) 1000110 c) 1100011 1.9 Find the 9’s and 10’s complement of the following numbers: a) 563 b) 24 c) 1079 Answers for exercises 1.1 a) 13, 11, B b) 66, 54, 36 c) 13.4, 11.5, B.8 d) 66.64, 54.81249, 36.D
  • 33.
    Number Systems 1.33 1.2a) 11001, 31, 19 b) 101110111, 567, 177 c) 10001010.1110001111...., 103.7075....., 43.E3D7.... d) 10001010.101010000....., 212.5203......, 8A.A831.... 1.3 a) 11111, 31, 1F b) 110010, 50, 32 c) 10011.00101, 19.156249, 13.28 d) 101100.110010011, 44.78710...., 2C.C98 1.4 a) 11001, 31, 25 b) 10101111, 257, 175 c) 11000001.0101011, 301.254, 193.3359..... d) 101111001101.0001001, 5715.044, 3021.07031..... 1.5 a) 10000, 110, 110111, 10.0011 b) 101001, 10011, 101001010, 10.10111.... 1.6 a) 70, 26, 1227, 2.226455..... b) 401, 245, 22752, 4.4544.... 1.7 a) FD6, F90, 22579, 72.D41 b) B875, B69D, A9324C, C7.16C7.... 1.8 a) 0100, 0101 b) 0111001, 0111010 c) 0011100, 0011101 1.9 a) 436, 437 b) 75, 76 c) 8920, 8921