CHAPTER1
CHAPTER1
CHAPTER1
CHAPTER 1
NUMBER SYSTEMS
INTRODUCTION
The base of a number system is the number of digits it uses. The decimal number
system has base of 10 because it uses the digits 0 to 9. The binary number system has a
base of 2 because it uses the digits 0 and 1. The octal number system has a base of 8. It
uses the digits 0 to 7. Hexadecimal number system has a base of 16. It uses the digits 0 to 9
and A to F.
DECIMAL NUMBER SYSTEM
The decimal system is composed of 10 numerals or symbols. These 10 symbols are
0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. Using these symbols, we can express any quantity. The
decimal system is called the base-10 system because it has 10 digits. The decimal system is
a positional-value system, wherein each digit has its own value or weight expressed as a
power of 10. This is illustrated in Fig. 1.1. Here, places to the left of the decimal point are
positive powers of 10 and places to the right are negative powers of 10.
Decimal weight: 104 103 102 101 100 . 10-1 10-2 10-3
Decimal value: 10000 100 100 10 1 . 0.1 0.01 0.001
0
↑ ↑ ↑
MSD Decimal LSD
point
Fig. 1.1: Decimal position values (weights) as powers of 10
BINARY NUMBER SYSTEM
In the binary system there are only two symbols or digit values, 0 and 1. This base-2
system can be used to represent any quantity that can be represented in decimal or other
number systems. The binary system is a positional-value system, wherein each binary digit
has its own value or weight expressed as a power of 2. This is illustrated in Fig. 1.2. Here,
places to the left of the binary point are positive powers of 2 and places to the right are
negative powers of 2.
Binary weight: 26 25 24 23 22 21 20 . 2-1 2-2 2-3
Decimal value: 64 3 16 8 4 2 1 . 0.5 0.25 0.125
2
↑ ↑ ↑
MSB Binary LSB
point
Fig. 1.2: Binary position values (weights) as powers of 2
OCTAL NUMBER SYSTEM
The octal number system has a base of eight, meaning that it has eight possible
digits: 0, 1, 2, 3, 4, 5, 6 and 7. Thus, each digit of an octal number can have any value from
0 to 7. The octal system is a positional-value system, wherein each digit has its own value or
weight expressed as a power of 8.The digit positions in an octal number have weights as
shown in Fig. 1.3. Here, places to the left of the octal point are positive powers of 8 and
places to the right are negative powers of 8.
Octal weight: 84 83 82 81 80 . 8-1 8-2 8-3
Decimal value: 4096 512 64 8 1 . 0.125 0.016 0.002
↑ ↑ ↑
MSD Octa LSD
l
point
Fig. 1.3: Octal position values (weights) as powers of 8
HEXADECIMAL NUMBER SYSTEM
The hexadecimal number system has a base of 16, meaning that it has sixteen
possible digits: 0 through 9 plus the letters A, B, C, D, E and F. Thus, each digit of an octal
number can have any value from 0 to F. The hexadecimal system is a positional-value
2
system, wherein each digit has its own value or weight expressed as a power of 16. The digit
positions in a hexadecimal number have weights as shown in Fig. 1.4. Here, places to the
left of the hexadecimal point are positive powers of 16 and places to the right are negative
powers of 16.
Hexadecimal weight: 163 162 161 160 . 16-1 16-2
Decimal value: 4096 256 16 1 . 0.062 0.004
5
↑ ↑ ↑
MSD Hexadecimal LSD
point
Fig. 1.4: Hexadecimal position values (weights) as powers of 16
Hexadecimal numbers are used extensively in microprocessor based systems and
computers. They are shorter than binary numbers. It is easy to write and remember
hexadecimal numbers. It is easy to convert hexadecimal numbers to binary.
Table. 1.1 shows the relationship among hexadecimal, decimal and binary. Each
hexadecimal digit represents a group of four binary digits. Hex digits A through F are
equivalent to the decimal values 10 through 15.
Hexadecimal Decimal Binary
Digit
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111
Table. 1.1 Relationship among hexadecimal, decimal and binary
SUBSCRIPTS
Subscripts are used to represent the base of the number system as shown in Table.
1.2.
Number Subscript Example
system equations
Binary 2 12 + 12 = 102
Octal 8 78 + 18 = 108
Decimal 10 910 + 110 = 1010
Hexadecimal 16 F16 + 116 = 1016
Table. 1.2 Subscripts
BINARY TO DECIMAL CONVERSION
When converting from binary to decimal, each digit must be multiplied by its weight
and the resulting products should be added.
Example 1. Convert 11011012 to decimal.
Solution:
Binary number: 1 1 0 1 1 0 1
Binary weight: 26 25 24 23 22 21 20
Decimal value: 64 3 16 8 4 2 1
2
1101101 2 =64×1+32×1+16×0+8×1+4×1+2×0+1×1
=64×1+32×1+16×0+ 8×1+ 4×1+ 2×0+1×1
=64 +32+0+8+ 4+ 0+1=109
3
=109
11011012 = 10910
Example 2. Determine the decimal value of the fractional binary number 0.1011.
Solution:
Binary number: 0 . 1 0 1 1
Binary weight: 20 . 2-1 2-2 2-3 2-4
Decimal value: 1 . 0.5 0.25 0.125 0.0625
0 .1011 2 =(1×0 ).(0 . 5×1+ 0. 25×0+0 . 125×1+0 . 0625×1 )
=(0).(0 .5+0+0 .125+ 0. 0625 )=0 . 6875
0.10112 = 0.672510
Example 3. Convert 1001.1012 to decimal.
Solution:
Binary number: 1 0 0 1 . 1 0 1
Binary weight: 23 22 21 20 . 2-1 2-2 2-3
Decimal value: 8 4 2 1 . 0.5 0.25 0.125
1001. 101 2 =( 8×1+4×0+2×0+ 1×1) .(0 .5×1+0 .25×0+0. 125×1 )
=(8+0+0+1). (0. 5+0+ 0. 125 )=9 . 625
1001.1012 = 9.62510
OCTAL TO DECIMAL CONVERSION
When converting from octal to decimal, each digit must be multiplied by its weight
and the resulting products should be added.
Example 1. Convert 23758 to decimal.
Solution:
Octal number: 2 3 7 5
Octal weight: 83 82 81 80
Decimal value: 512 64 8 1
23748 =512×2+ 64×3+8×7+1×5
=1024+ 192+ 56+5
=127710
23758 = 127710
Example 2. Convert 0.3258 to decimal.
Solution:
Octal number: 0 . 3 2 5
Octal weight: 80 . 8-1
8-2
8-3
Decimal value: 1 . 0.125 0.016 0.002
0 .325 8=(1×0 ).(0. 125×3+0 .016×2+0 . 002×5 )
=(0).(0 .375+0. 032+0 . 01)
=0 . 417 10
0.3258 = 0.41710
Example 3. Convert 24.68 to decimal.
Solution:
Octal number: 2 4 . 6
Octal weight: 81 80 . 8-1
Decimal value: 8 1 . 0.125
24 . 68 =( 8×2+1×4 ). (0. 125×6)
=(16+4 ).(0 .75 )
=20 . 7510
24.68 = 20.7510
4
Solution:
Integer part conversion
Remainder
16 894 → E (LSD)
16 55 → 7
16 3 → 3 (MSD)
0
89410 = 37E16
Hexadecimal 4-bit
Digit Binary
Equivalent
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111
Table. 1.4: Hexadecimal to binary conversion
Example. 1. Convert A2F416 to binary.
Solution:
Hexadecimal A 2 F 4
number:
↓ ↓ ↓ ↓
Binary equivalent: 1010 0010 1111 0100
A2F416 = 10100010111101002
Example 2. Represent 0.A416 by its binary equivalent fraction.
Solution:
Hexadecimal number: 0 . A 4
↓ ↓ ↓ ↓
Binary equivalent: 0000 . 1010 0100
0.A416 = 0000.101001002
Example 3. Represent B3.A216 by its binary equivalent.
Solution:
Hexadecimal B 3 . A 2
number:
↓ ↓ ↓ ↓ ↓
Binary equivalent: 1011 001 . 1010 0010
1
B3.A28 = 10110011.101000102
BINARY TO OCTAL CONVERSION
When converting from binary to octal, group the bits in threes starting at the binary
point. Then convert each group of three bits to its octal equivalent. 0s can be added if
necessary. For example, 11.012 = 011.0102.
Example 1. Represent 10111001102 by its octal equivalent.
Solution: Add 0s so that the given binary number can be arranged in groups of 3 bits.
9
10111001102 = 0010111001102
Binary number: 001 011 100 110
↓ ↓ ↓ ↓
Octal 1 3 4 6
equivalent:
10111001102 = 13468
1+0= 1
1 + 1 = 102
Three of the addition rules result in a single bit. Addition of two 1s yields a binary two
(102). This condition creates a sum of 0 and a carry of 1 over to the next higher column.
When there is a carry, three bits are being added. The rules for this are as follows:
1+ 0 + 0 = 01 1 with a carry of 0
1+ 0 + 1 = 10 0 with a carry of 1
1+ 1 + 0 = 102 0 with a carry of 1
1+ 1 + 1 = 112 1 with a carry of 1
DIVISION
Division in binary follows the same procedure as division in decimal.
Example 1. Perform the following binary division: 110÷11
Solution:
¿¿¿¿¿
Example 2. Perform the following binary division: 1111. 0÷110
Solution:
always represents the sign and the remaining bits stand for the magnitude. Some examples
of sign-magnitude numbers are as follows:
+710 = 0000 0111
-1610 = 1001 0000
With an 8-bit sign-magnitude number, the largest magnitude is 127. The largest
magnitude is approximately half that of unsigned binary numbers. The negative numbers are
1000 0000 to 1111 1111 (-1 to -127). The positive numbers are 0000 0001 to 0111 1111 (+1
to +127).
Merits
Simplicity.
It is easy to find the magnitude by deleting the sign bit.
Demerits
Complicated arithmetic circuits are required handle sign-magnitude numbers.
Applications
Suitable in situations where there is no need to add or subtract the data.
Analog-to-digital conversions
1’S COMPLEMENT OF A BINARY NUMBER
The 1’s complement of a binary number is found by simply changing all 1s to 0s and
all 0s to 1s.
Examples: Find the 1’s complement of the binary numbers:
Binary 1’s
number Complement
10101 01010
10111 01000
111100 000011
11011011 00100100
1’S COMPLEMENT SUBTRACTION
1’s complement method allows us to subtract binary numbers using only addition.
Merits
Subtraction can be accomplished with an adder.
1’s complement of a number is easily obtained by inverting each bit in the number.
Applications
Arithmetic logic circuits
Subtracting a Smaller Number from a Larger Number
The format for subtraction is
Minuend - Subtrahend = Difference
To subtract a smaller number from a larger number, the 1’s complement method is
as follows:
1. Write down the minuend.
2. Determine the 1’s complement of the subtrahend.
3. Add the 1’s complement to the minuend.
4. Remove end-around carry and add it to the result to get the final answer.
Example 1. Subtract 100112 from 110012 using 1’s complement method.
Solution: It is required to perform 110012 - 100112.
Minuend = 11001
Subtrahend = 10011
11001 Minuend
+ 01100 1’s complement of the subtrahend
1 00101
+1 Add end-around carry
00110 Final answer
Example 2. Subtract 6810 from 12510 using 1’s complement method.
Solution: It is required to perform 12510 - 6810.
Minuend = 12510 = 1111101
Subtrahend = 6810 = 1000100
13
1111101 Minuend
+ 0111011 1’s complement of the subtrahend
1 0111000
+1 Add end-around carry
0111001 Final answer (= 5710)
Subtracting a Larger Number from a Smaller Number
To subtract a larger number from a smaller number, the 1’s complement method is
as follows:
1. Write down the minuend.
2. Determine the 1’s complement of the subtrahend.
3. Add the 1’s complement to the minuend. There is no carry. The result has an
opposite sign and is in the 1’s complement of the answer.
4. To get the answer in the true form, take the 1’s complement and change the sign.
Example 1. Subtract 11012 from 10012 using 1’s complement method.
Solution: It is required to perform 10012 - 11012.
Minuend = 1001
Subtrahend = 1101
1001 Minuend
+ 0010 1’s complement of the subtrahend
No carry; 1’s complement of the answer
1011
and opposite in sign
- 0100 Final answer (-410)
Example 2. Subtract 10810 from 1410 using 1’s complement method.
Solution: It is required to perform 1410 - 10810.
Minuend = 1410 = 0001110
Subtrahend = 10810 = 1101100
0001110 Minuend
+ 0010011 1’s complement of the subtrahend
0100001 No carry; 1’s complement of the answer
and opposite in sign
- 1011110 Final answer (-9410)
2’S COMPLEMENT OF A BINARY NUMBER
There are two methods of finding the 2’s complement of a binary number.
Method 1
The 2’s complement of a binary number is found by adding 1 to the 1’s complement.
Example 1. Find the 2’s complement of the binary number 110.
Solution:
110 Binary Number
001 1’s complement of 110
+1 Add 1
010 2’s complement of 110
Example 2. Find the 2’s complement of the binary number 10101.
Solution:
1010 Binary Number
1
0101 1’s complement of 10101
0
+1 Add 1
0101 2’s complement of 10101
1
Method 2
14
Applications
Microcomputer architecture and programming
Subtracting a Smaller Number from a Larger Number
To subtract a smaller number from a larger number, the 2’s complement method is
as follows:
1. Write down the minuend.
2. Determine the 2’s complement of the subtrahend.
3. Add the 2’s complement to the minuend.
4. Discard the carry.
Example 1. Subtract 10112 from 11002 using 2’s complement method.
Solution: It is required to perform 11002 - 10112.
Minuend = 1100
Subtrahend = 1011
1100 Minuend
+ 0101 2’s complement of the subtrahend
1 0001 Discard carry
0001 Final answer
Example 2. Subtract 6810 from 12510 using 2’s complement method.
Solution: It is required to perform 12510 - 6810.
Minuend = 12510 = 1111101
Subtrahend = 6810 = 1000100
1111101 Minuend
+ 0111100 2’s complement of the subtrahend
1 0111001 Discard carry
0111001 Final answer (= 5710)
Subtracting a Larger Number from a Smaller Number
To subtract a larger number from a smaller number, the 2’s complement method is
as follows:
1. Write down the minuend.
2. Determine the 2’s complement of the subtrahend.
15
3. Add the 2’s complement to the minuend. There is no carry. The result has an
opposite sign and is in the 2’s complement of the answer.
4. To get the answer in the true form, take the 2’s complement and change the sign.
Example 1. Subtract 111002 from 100112 using 2’s complement method.
Solution: It is required to perform 100112 - 111002.
Minuend = 10011
Subtrahend = 11100
10011 Minuend
+ 00100 2’s complement of subtrahend
10111 No carry; 2’s complement of the answer
and opposite in sign
- 01001 Final answer
Example 2. Subtract 10810 from 1410 using 2’s complement method.
Solution: It is required to perform 1410 - 10810.
Minuend = 1410 = 0001110
Subtrahend = 10810 = 1101100
0001110 Minuend
+ 0010100 2’s complement of the subtrahend
0100010 No carry; 2’s complement of the answer
and opposite in sign.
- 1011110 Final answer (-9410)
9’S COMPLEMENT OF A DECIMAL NUMBER
The 9’s complement of a decimal number is found by subtracting each digit in the
number from 9 as shown in Table. 1.5.
Subtrahend = 2110
54 Minuend
+ 9’s complement of subtrahend
78
1 32
+ 1 Add end-around carry
33 Final answer
Example 2. Subtract 12210 from 12610 using 9’s complement method.
Solution: It is required to perform 12610 - 12210.
Minuend = 12610
Subtrahend = 12210
126 Minuend
+ 9’s complement of subtrahend
877
1 003
+ 1 Add end-around carry
04 Final answer
Subtracting a Larger Number from a Smaller Number
To subtract a larger number from a smaller number, the 9’s complement method is
as follows:
1. Write down the minuend.
2. Determine the 9’s complement of the subtrahend.
3. Add the 9’s complement to the minuend. There is no carry. The result has an
opposite sign and is in the 9’s complement of the answer.
4. To get the answer in the true form, take the 9’s complement and change the sign.
Example 1. Perform the hex subtraction using 2’s complement method: 8416 - 2A16.
Solution:
Minuend = 8416
Subtrahend = 2A16 = 001010102
2’s complement of subtrahend = 110101102 = D616
8416 Minuend
+ D616 2’s complement of subtrahend
1 5A16 Discard carry
5A16 Final answer
Example 2. Perform the hex subtraction using 2’s complement method: 8416 - FA16.
Solution:
Minuend = 8416
Subtrahend = FA16 = 111110102
2’s complement of subtrahend = 000001102 = 0616
2’s complement of 8A16 = 2’s complement of 100010102 = 011101102 = 7616
8416 Minuend
+ 0616 2’s complement of subtrahend
8A16 No carry; 2’s complement of the answer
and opposite in sign.
- 7616 Final answer
STUDY OF CODES
The process of representing numbers, letters or words by a special group of symbols
is called encoding and the group of symbols is called a code.
19
To determine a decimal number from a BCD number, start at the decimal point and
break the code into groups of four bits. Then write the decimal digit represented by each
four-bit group.
Example 1. Convert BCD number 100101100100 to its decimal equivalent.
Solution:
BCD: 0001 0110 0100
↓ ↓ ↓
Decimal: 9 6 4
100101100100 (BCD) = 964 (Decimal)
EXCESS-3 CODE
Decimal BCD Excess-3
0 000 0011
0
1 000 0100
1
2 001 0101
0
3 001 0110
1
4 010 0111
0
5 010 1000
1
6 011 1001
0
7 011 1010
1
8 100 1011
0
9 100 1100
1
Table. 1.7: Excess-3 code
The excess-3 code is a 4-bit code used with binary-coded decimal (BCD) numbers.
To convert any decimal number into its excess-3 form, 3 is added to each decimal digit and
the sum is converted into a BCD number. Since no definite weights can be assigned to the
four digit positions, Excess-3 is an unweighted code. The minimum distance of Excess-3
code is 1. It is the smallest number of bits by which any two successive code words differ.
Table. 1.7 shows the excess-3 code for each decimal digit.
Ten of possible 16-code combinations are used in the Excess-3 code. The six invalid
combinations are 0000, 0001, 0010, 1101, 1110 and 1111. The key feature of the Excess-3
code is that it is self-complementing. Excess-3 code is a self-complementing code. That is,
Excess-3 code for 9’s complement of N is the 1’s complement of the Excess-3 code for N. It
is used in some arithmetic circuits.
Example:
Let N be 0001.
Excess-3 code for N is 0100.
1’s complement of excess-3 code for N = 1’s complement of 0100 = 1011.
9’s complement of N = 9’s complement of 0001 = 9 - 1 = 8 = 1000.
Excess-3 code for 9’s complement of N = Excess-3 code for1000 = 1011.
DECIMAL TO EXCESS-3 CODE CONVERSION
To convert decimal to Excess-3 code, add 3 to each digit in the decimal number and
then convert each resulting sum to its equivalent binary code.
B 1=B2 ⊕G1
B 0 =B 1 ⊕ G 0
Example 1. Convert Gray code 0101 to binary.
Solution:
G3 G2 G1 G0 = 0101
B 3 =G3=0
B 2=B3 ⊕ G 2 =1
B 1=B2 ⊕ G 1 =1
B 0 =B 1 ⊕ G 0=0
0101 (Gray) = 0110(Binary)
ALPHANUMERIC CODES
In addition to numerical data, a computer must be able to handle non-numerical
information such as letters of the alphabet, punctuation marks and other special characters
using codes. These codes are called alphanumeric codes. A complete alphanumeric code
would include the 26 lowercase letters, 26 uppercase letters, 10 numeric digits, 7
punctuation marks and other characters such as +, /, £, @, % and so on. An alphanumeric
code represents all the various characters and functions that are found on a computer
keyboard.
AMERICAN STANDARD CODE FOR INFORMATION INTERCHANGE (ASCII) CODE
The most widely used alphanumeric code is the ASCII code. It is an unweighted 7-
bit code. ASCII code allows manufacturers to standardize computer hardware such as
keyboards, printers and video displays. The features of ASCII are as follows:
1. Each code word consists of 7 bits. Hence, we have a total of 2 7 (= 128) possible
combinations to represent letters in the alphabet, punctuation marks and numbers.
2. There is a definite order in which symbols are assigned to each code word. The code
is divided into two groups. The first three bits in the code are used to identify whether
the remaining four bits represent letters, numerals or punctuation marks. For
example, 100 and 101 represent upper-case letters. Upper-case letter A is
represented by 100 0001 (4116), B is represented by 100 0001 (4216) and so on. 110
and 111 represent lower-case letters. Lower-case letter a is represented by 110 0001
(6116), b is represented by 110 0001 (6216) and so on.
3. Redundant bits can be added for error-detection and correction.
EXTENDED BINARY CODED DECIMAL INTERCHANGE CODE (EBCDIC)
EBCDIC is an 8-bit alphanumeric code in which decimal digits are represented by the
8421 BCD code preceded by 1111. Both lowercase and uppercase letters are represented in
addition to numerous other symbols and commands. The features of ASCII are as follows:
Each code word consists of 8 bits. Hence, we have a total of 2 8 (= 256) possible
combinations to represent letters in the alphabet, punctuation marks and numbers.
The code is divided into two groups. Each group contains four bits.
IMPORTANT POINTS
5. The base of a number system equals the number of digits it uses.
6. Weight refers to the decimal value of each digit position of a number.
7. Bit is an abbreviated form of binary digit.
8. When converting from binary (or octal or hex) to decimal, use the method of taking
the weighted sum of each digit position.
24
9. When converting from decimal to binary (or octal or hex), use the method of
repeatedly dividing by 2 (or 8 or 16) and collecting the remainders.
10. When converting from binary to octal (or hex), arrange the bits in groups of three (or
four) and convert each group into the correct octal (or hex) digit.
11. When converting from octal (or hex) to binary, convert each digit into its three-bit (or
four-bit) equivalent.
12. When converting from octal to hex (or vice versa), first convert to binary, then convert
binary into the desired number system.
13. The 1’s complement of a binary number is found by simply changing all 1s to 0s and
all 0s to 1s.
14. The 2’s complement of a binary number = 1’s complement + 1.
15. To represent signed numbers in binary, a sign bit is attached as the MSB. Positive
numbers have a sign bit of 0 and negative numbers have a sign bit of 1.
16. Positive numbers are represented by a sign bit of 0 followed by the magnitude in its
true binary form.
17. Negative numbers are represented by a sign bit of 1 followed by the magnitude in 2’s
complements form.
18. Taking 2’s complement is equivalent to negation or changing the sign of the number.
19. The two numbers in an addition are the addend and the augend.
20. The two numbers in a subtraction are the subtrahend and the minuend.
21. If a four-bit sum is greater than 9 in BCD addition, 6 (0110 2) is added to the four-bit
sum as a corrective step.
22. The 7-bit ASCII code is an alphanumeric code widely used for transferring data into
and out of a computer.
23. Excess-3 code is a self-complementing code. That is, Excess-3 code for 9’s
complement of N is the 1’s complement of the Excess-3 code for N.
24. The minimum distance of Excess-3 code is 1. It is the smallest number of bits by
which any two successive code words differ.
25. The important property of the Gray code is that it exhibits only a single-bit change
from one code number to the next.
REVIEW QUESTIONS
Objective Type
1) In the hex counting sequence, the number after E9F is .
2) is an abbreviated form of binary digit.
3) code is an alphanumeric code widely used in computer system.
4) 25510 = 2.
5) 11111112 = 10.
6) 51110 = 8.
7) 2358 = 10.
8) 7A916 = 10.
9) 160010 = 16.
10) 8610 = (BCD).
11) 1001 0100 (BCD) = 10.
12) 468 = 16.
13) B316 = 8.
14) 01110100 (BCD) = 2.
15) 1110102 = (BCD).
16) Conversion from decimal to requires repeated division by 8.
17) Conversion from decimal to hex requires repeated division by .
18) In code, only one bit changes from one step to the next.
19) code is a self-complementing code.
20) The hexadecimal system uses symbols.
21) The 2’s complement number 0111 represents in binary.
22) The 2’s complement number 0111 represents in decimal.
23) The 2’s complement number 1111 represents in decimal.
25