EEC2102-Week 5-Lecture-Chapter-4-1
EEC2102-Week 5-Lecture-Chapter-4-1
TECHNOLOGY
Master the skill of converting between various radix systems e.g converting between decimal and
binary number systems,
Understand how errors can occur in computations because of overflow and truncation.
All numbers in the binary system are represented to base 2, in terms of ‘0’ and ‘1’.
Starting from the binary point, the place values of different digits in a mixed binary
number are 20 , 21 , 22 and so on (for the integer part) and 2−1 , 2−2 , 2−3 and so on (for
the fractional part).
Example 4.1
Obtain the decimal equivalent of the following mixed binary number: 1001.101
Solution
1001.101 = 𝟐𝟑 × 𝟏 + 𝟐𝟐 × 𝟎 + 𝟐𝟏 × 𝟎 + 𝟐𝟎 × 𝟏 + 𝟐−𝟏 × 𝟏 + 𝟐−𝟐 × 𝟎 + 𝟐−𝟑 × 𝟏
= 𝟐𝟑 + 𝟐𝟎 + 𝟐−𝟏 + 𝟐−𝟑 = 𝟖 + 𝟏 + 𝟎. 𝟓 + 𝟎. 𝟏𝟐𝟓 = 𝟗. 𝟔𝟐𝟓𝟏𝟎
9/21/2024 EEC2102 Lecture Notes by Dr. L. A. Aloo 6
CHAPTER 4: NUMBER SYSTEMS AND COMPUTER ARITHMETIC
4.3.1. Binary Number System
Advantages of Binary Number System
1. Logic operations on modern digital computers can be conveniently done in
binary number system.
2. All kinds of data could be conveniently represented in terms of 0’s and 1’s.
3. Basic electronic devices used for hardware implementation can be conveniently
and efficiently operated in two distinctly different modes.
4. The circuits required for performing arithmetic operations such as addition,
subtraction, multiplication, division, etc., become a simple affair in the binary
number system.
The binary numbering system is the most important radix system for digital Decimal Binary Hexadecimal Octal
computers. 0 00000 0 0
However, it is difficult to read long strings of binary numbers -- and even a 1 0001 1 1
modestly-sized decimal number becomes a very long binary number. 2 0010 2 2
3 0011 3 3
For example: 110101000110112 = 1359510 4 0100 4 4
For compactness and ease of reading, binary values are usually 5 0101 5 5
6 0110 6 6
expressed using the hexadecimal, or base-16, numbering system.
7 0111 7 7
8 1000 8 10
A sequence of hexadecimal digits can be thought of as 9 1001 9 11
10 1010 A 12
representing an integer in base 16 (Table 4.1). 11 1011 B 13
Binary digits are grouped into sets of four bits, called a 12 1100 C 14
13 1101 D 15
nibble. 14 1110 E 16
15 1111 F 17
9/21/2024 EEC2102 Lecture Notes by Dr. L. A. Aloo 8
CHAPTER 4: NUMBER SYSTEMS AND COMPUTER ARITHMETIC
4.3.4. Hexadecimal Number System
Example 4.2
To illustrate this last point, consider the binary string 110111100001. Obtain its
hexadecimal equivalent.
Solution
First, group the binary string into groups of 4 binary digits each.
𝟏𝟏𝟎𝟏 𝟏𝟏𝟏𝟎 𝟎𝟎𝟎𝟏 = 𝑫𝑬𝟏 𝟏𝟔
D E 1
Similarly, the contents of the memory when represented in hexadecimal form
are very convenient to handle.
9/21/2024 EEC2102 Lecture Notes by Dr. L. A. Aloo 9
CHAPTER 4: NUMBER SYSTEMS AND COMPUTER ARITHMETIC
4.4. Converting Between Bases
2 11 1 bottom is:
2 5 1 0.812510 = 0.11012
2 2 1 This method also works with any
2 1 0 base. Just use the target radix as the
0 1 multiplier.
9/21/2024 EEC2102 Lecture Notes by Dr. L. A. Aloo 10
CHAPTER 4: NUMBER SYSTEMS AND COMPUTER ARITHMETIC
4.4. Converting Between Bases
Using groups of hextets, the binary number 110101000110112 (= 1359510) in hexadecimal is:
Octal (base 8) values are derived from binary by using groups of three bits (8 = 23):
In an 8-bit word, signed magnitude representation places the absolute value of the number in the
7 bits to the right of the sign bit.
For example, in 8-bit signed magnitude representation:
+3 is: 00000011
- 3 is: 10000011
Computers perform arithmetic operations on signed magnitude numbers in much the same way
as humans carry out pencil and paper arithmetic.
Humans often ignore the signs of the operands while performing a calculation, applying the
appropriate sign after the calculation is complete.
9/21/2024 EEC2102 Lecture Notes by Dr. L. A. Aloo 14
CHAPTER 4: NUMBER SYSTEMS AND COMPUTER ARITHMETIC
4.5. Computer Arithmetic
4.5.4. Signed Integer Representation Example 4.3: Using signed magnitude
Example 4.5
Find the decimal equivalent of the binary number 00001110 which is expressed in the 2’s complement
format:
Solution
The MSB bit is ‘0’, which indicates a plus sign.
The magnitude bits are: 0001110.
The decimal equivalent = 0 × 𝟐𝟎 + 𝟏 × 𝟐𝟏 + 𝟏 × 𝟐𝟐 + 𝟏 × 𝟐𝟑 + 𝟎 × 𝟐𝟒 × 𝟎 × 𝟐𝟓 + 𝟎 × 𝟐𝟔
= 𝟐𝟏 + 𝟐𝟐 + 𝟐𝟑 = 𝟏𝟒𝟏𝟎
Therefore, 00001110 represents +𝟏𝟒
Example 4.6
Find the decimal equivalent of the binary number 10001110 which is expressed in the 2’s
complement format.
Solution
The MSB bit is ‘1’, which indicates a minus sign.
The magnitude bits are therefore given by the 2’s complement of 0001110, i.e. 1110010.
The decimal equivalent = 0 × 𝟐𝟎 + 𝟏 × 𝟐𝟏 + 𝟎 × 𝟐𝟐 + 𝟎 × 𝟐𝟑 + 𝟏 × 𝟐𝟒 × 𝟏 × 𝟐𝟓 + 𝟏 × 𝟐𝟔
= 𝟐𝟏 + 𝟐𝟒 + 𝟐𝟓 + 𝟐𝟔 = 𝟐 + 𝟏𝟔 + 𝟑𝟐 + 𝟔𝟒 = 𝟏𝟏𝟒𝟏𝟎
Therefore, 10001110 represents −𝟏𝟏𝟒.
• Example 4.7:
Rule for detecting signed two’s complement overflow: When the “carry in” and
the “carry out” of the sign bit differ, overflow has occurred. If the carry into the
sign bit equals the carry out of the sign bit, no overflow has occurred.
3. Excess-3
2 7
• -Obtained by adding 3 to each decimal digit and converting to3 binary
3 in groups of 4-bits
5 10 convert to binary = 0101 1010
• Combine them to form a string of bits-
2710 = 01011010Excess-3
4. Gray Code
• -This represents the numbers in a way that each consecutive number will differ by 1 in binary form
Converting from Binary to Gray Code
• Steps
• Most Significant Bit (MSB) remains the same
• 2nd bit is obtained by adding the MSB bit and the 2nd bit of binary then discard the carry
• 3rd bit is obtained by adding 2nd bit to 3rd bit of binary also discard the carry
9/21/2024
• Continue until all the bits are considered. 10112 = 1110gray code
EEC2102 Lecture Notes by Dr. L. A. Aloo 24
CHAPTER 4: NUMBER SYSTEMS AND COMPUTER ARITHMETIC
• Steps
• 2nd bit is obtained by adding the MSB bit of the binary to the 2nd bit of gray code then
discard the carry
• ASCII Code
• -This is an alpha-numeric code, Represents decimal digits and alphabets in binary and other
symbols
9/21/2024 EEC2102 Lecture Notes by Dr. L. A. Aloo 25
CHAPTER 4: NUMBER SYSTEMS AND COMPUTER ARITHMETIC
The 7 bit ASCII code
Bit Positions Bit Positions 654
3210
000(0) 001(1) 010(2) 011(3) 100(4) 101(5) 110(6) 111(7)
• For example:
For example, decimal numbers 0.0003754 and 3754 will be represented in floating-point
In the case of normalized binary numbers, the leading digit (i.e. the most significant bit),
.1101011 × 23 = .1101011𝑒 + 0011. Here, .1101011 is the mantissa and 𝑒 + 0011 implies