Vous êtes sur la page 1sur 29

1

DIGITAL COMPUTERS
AND INFORMATION

L
ogic design fundamentals and computer design fundamentals are the topics of this book.
Logic design deals with the basic concepts and tools used to design digital hardware
consisting of logic circuits. Computer design deals with the additional concepts and tools used to
design computers and other complex digital hardware. Computers and digital hardware in general are
referred to as digital systems. Thus, this book is about understanding and designing digital systems. Due
to its generality and complexity, the computer provides an ideal vehicle for learning the concepts of, and
tools for, digital system design. In addition, due to its widespread use, the computer itself is deserving of
study. Hence, the focus in this book is on computers and their design.
The computer will be not only a vehicle, but also a motivator for study. To this end, we use the
exploded pictorial diagram of a computer of the class commonly referred to as a PC
(personal computer) given on the opposite page. We use this generic computer to highlight the significance
of the material covered and its relationship to the overall system. A bit later in the chapter, we will discuss
the various major components of the generic computer and see how they relate to a block diagram often
used to describe a computer.

1-1 DIGITAL COMPUTERS


Today, digital computers have such a prominent and growing role in modern society that we often say
we are in the ‘‘information age.’’ Computers are involved in our business transactions, communications,
transportation, medical treatment, and entertainment. They monitor our weather and environment. In the
industrial world, they are heavily employed in design, manufacturing, distribution, and sales. They have
contributed to many scientific discoveries and engineering developments that would have been unat-
tainable otherwise. Notably, the design of a new processor for a modern computer could not be done
without the use of many computers!
Monitor
Hard Disk
Keyboard

Disk Controller
Bus Interface

Graphics Adapter
Internal
FPU Cache
CPU MMU
Processor

RAM
External
Cache
DIGITAL COMPUTERS AND INFORMATION 3
The most striking property of the digital computer is its generality. It can follow a sequence of
instructions, called a program, that operates on given data. The user can specify and change the program
or the data according to specific needs. As a result of this flexibility, general-purpose digital computers
can perform a variety of information-processing tasks that range over a very wide spectrum of applica-
tions. The general-purpose digital computer is the best known example of a digital system. Character-
istic of a digital system is its manipulation of discrete elements of information. Any set that is restricted
to a finite number of elements contains discrete information. Examples of discrete sets are the 10 deci-
mal digits, the 26 letters of the alphabet, the 52 playing cards, and the 64 squares of a chessboard. Early
digital computers were used mostly for numeric computations. In this case, the discrete elements used
were the digits. From such an application, the term digital computer emerged.
Discrete elements of information are represented in a digital system by physical quantities called
signals. Electrical signals such as voltages and currents are most common. Electronic devices called
transistors predominate in the circuitry that implements these signals. The signals in most present-day
electronic digital systems use just two discrete values and are therefore said to be binary.
We typically represent the two discrete values by ranges of voltage values called HIGH and LOW.
Output voltage ranges and input voltage ranges are illustrated in Figure 1-1. The HIGH output voltage
value ranges between 4.0 and 5.5 volts, and the LOW output voltage value ranges between – 0.5 and 1.0
volt. The high input range allows 3.0 to 5.5 volts to be recognized as a HIGH, and the low input range
allows – 0.5 to 2.0 volts to be recognized as a LOW. The fact that the input ranges are longer than the
output ranges allows the circuits to function correctly in spite of variations in their behavior and undesir-
able ‘‘noise’’ voltages that may be added to or subtracted from the outputs.
We give the output and input voltage ranges a number of different names. Among these are HIGH(H)
and LOW(L), TRUE(T) and FALSE(F), and 1 and 0.

OUTPUT INPUT
+5.5
5.0
HIGH HIGH
4.0
3.0
2.0
1.0
LOW LOW
0.0
Volts –0.5

FIGURE 1-1
An Example of Voltage Ranges for Binary Signals.

It is clear that the higher voltage ranges are associated with HIGH or H, and the lower voltage ranges
with LOW or L. We find, however, that for TRUE and 1 and FALSE and 0, there is a choice. TRUE and
1 can be associated with either the higher or lower voltage range and FALSE and 0 with the other range.
Unless otherwise indicated, we assume that TRUE and 1 are associated with the higher of the voltage
ranges, H, and that FALSE and 0 are associated with the lower of the voltage ranges, L. If the value of
input is between 2.0 and 3.0 volts (the forbidden or undefined range), the circuit will display an erratic
behavior and the circuit may malfunction.
4 LOGIC AND COMPUTER DESIGN FUNDAMENTALS

Why is binary used? In contrast to the situation in Figure 1-1, consider a system with 10 values
representing the decimal digits. In such a system, the voltages available—say, 0 to 5.0 volts—could be
divided into 10 ranges, each of length 0.5 volt. A circuit would provide an output voltage within each of
these 10 ranges. An input of a circuit would need to determine in which of the 10 ranges an applied
voltage lies. If we wish to allow for noise on the voltages, then output voltage might be permitted to
range over less than 0.25 volt for a given digit representation, and boundaries between inputs could vary
by only less than 0.25 volt. This would require complex and costly electronic circuits and still could be
disturbed by small ‘‘noise’’ voltages or small variations in the circuits occurring during their manufac-
ture or use. As a consequence, the use of such multivalued circuits is very limited. Instead, binary
circuits are used in which correct circuit operation can be achieved with significant variations in both,
the two output voltages and the two input ranges. The resulting transistor circuit with an output that is
either HIGH or LOW is simple, easy to design, and extremely reliable.
To summarize, the advantages of digital circuits are as follows:
1. One rarely needs to make finer distinctions between voltages.
2. Digital circuits are very tolerant to drift from 0 to 1 and hence the ageing effect is minimized.
3. It is easier to remember a 1 or a 0 as against remembering voltage values like 1.46 or 3.245.

Information Representation

Since 0 and 1 are associated with the binary number system, they are the preferred names for the signal
ranges. A binary digit is called a bit. Information is represented in digital computers by groups of bits.
By using various coding techniques, groups of bits can be made to represent not only binary numbers,
but also other groups of discrete symbols. Groups of bits, properly arranged, can even specify to the
computer, the instructions to be executed and the data to be processed.
Discrete quantities of information either emerge from the nature of the data being processed or
may be purposely quantized from continuous values. For example, a payroll schedule is inherently
discrete data containing employee names, social security numbers, weekly salaries, income taxes, and
so on. An employee’s paycheck is processed using discrete data values such as letters of the alphabet
(for the employee’s name), digits (for the salary), and special symbols such as $. On the other hand, an
engineer may measure the speed of rotation of an automobile wheel, which varies continuously with
time, but may record only specific values at specific times in tabular form. The engineer is thus quantiz-
ing the continuous data, making each number in the table a discrete quantity of information. In a case
such as this, if the measurement can be converted to an electronic signal, the quantization of the signal
in both value and time can be performed automatically by an analog-to-digital conversion device.

Computer Structure

A block diagram of a digital computer is shown in Figure 1-2. The memory stores programs as well as
input, output, and intermediate data. The datapath performs arithmetic and other data-processing opera-
tions as specified by the program. The control unit supervises the flow of information between the
various units. A datapath, when combined with the control unit, forms a component referred to as a
central processing unit, or CPU.
DIGITAL COMPUTERS AND INFORMATION 5
The program and data prepared by the user are transferred into memory by means of an input
device such as a keyboard. An output device, such as a CRT (cathode-ray tube) monitor, displays the
results of the computations and presents them to the user. A digital computer can accommodate many
different input and output devices, such as hard disks, floppy disk drives, CD-ROM drives, and scan-
ners. These devices use some digital logic, but often include analog electronic circuits, optical sensors,
CRTs or LCDs (liquid crystal displays), and electromechanical components.
The control unit in the CPU retrieves the instructions, one by one, from the program stored in the
memory. For each instruction, the control unit manipulates the datapath to execute the operation speci-
fied by the instruction. Both program and data are stored in memory. A digital computer is a powerful
system. It can perform arithmetic computations, manipulate strings of alphabetic characters, and be
programmed to make decisions based on internal and external conditions.

More on the Generic Computer

At this point, we will briefly discuss the generic computer and relate its various parts to the block
diagram in Figure 1-2. At the lower left of the diagram at the beginning of this chapter is the heart of the
computer, an integrated circuit called the processor. Modern processors such as this one are quite com-
plex and consist of millions of transistors. The processor contains four functional modules: the CPU, the
FPU, the MMU, and the internal cache.

Memory

Control
CPU unit Datapath

Input/Output

FIGURE 1-2
Block Diagram of a Digital Computer

We have already discussed the CPU. The FPU (floating-point unit) is somewhat like the CPU,
except that its datapath and control unit are specifically designed to perform floating-point operations.
In essence, these operations process information represented in the form of scientific notation (e.g.,
1.234 ¥ 107) permitting the generic computer to handle very large and very small numbers. The CPU
and the FPU, in relation to Figure 1-2, each contain a datapath and a control unit.
The MMU is the memory management unit. The MMU plus the internal cache and the separate
blocks near the bottom of the computer labeled ‘‘External Cache’’ and ‘‘RAM’’ (random access memory)
are all part of the memory in Figure 1-2. The two caches are special kinds of memory that allow the CPU
6 LOGIC AND COMPUTER DESIGN FUNDAMENTALS

and FPU to get at the data to be processed much faster than with RAM alone. RAM is what is most
commonly referred to as memory. As its main function, the MMU causes the memory that appears to be
available to the CPU to be much, much larger than the actual size of the RAM. This is accomplished by
data transfers between the RAM and the hard disk shown at the top of the picture of the generic com-
puter. So the hard disk, which we discuss later as an input/output device, appears conceptually as a part
of the memory and input/output.
The connection paths shown between the processor, memory, and external cache are the pathways
between integrated circuits. These are typically implemented as fine copper conductors on a printed
circuit board. The connection paths below the bus interface are referred to as the processor bus. The
connections above the bus interface are referred to as the input/output (I/O) bus. The processor bus and
the I/O bus attached to the bus interface carry data having different numbers of bits and have different
ways of controlling the movement of data. They may also operate at different speeds. The bus interface
hardware handles these differences so that data can be communicated between the two buses.
All of the remaining structures in the generic computer are considered part of I/O in Figure 1-2. In
terms of sheer physical volume, these structures dominate. In order to enter information into the
computer, a keyboard is provided. In order to view output in the form of text or graphics, a graphics
adapter card and CRT monitor are provided. The hard disk, discussed previously, is an electromechani-
cal magnetic storage device. It stores large quantities of information in the form of magnetic flux on
spinning disks coated with magnetic materials. In order to control the hard disk and transfer information
to and from it, a disk controller is used. The keyboard, graphics adapter card, and disk controller card are
all attached to the I/O bus. This allows these devices to communicate through the bus interface with the
CPU and other circuitry connected to the processor buses.
The generic computer consists mainly of an interconnection of digital modules. To understand the
operation of each module, it is necessary to have a basic knowledge of digital systems and their general
behavior. Chapters 1 through 7 of this book deal with logic design of digital circuits in general. Chapters
8 through 11 discuss the primary components of a digital system, their operation, and their design. The
operational characteristics of RAM are explained in Chapter 12. Datapath and control for simple com-
puters are introduced in Chapter 14. Chapters 15 through 18 present the basics of computer design.
Typical instructions employed in computer instruction set architectures are presented in Chapter 15.
The architecture and design of CPUs are examined in Chapter 16. Input and output devices and the
various ways that a CPU can communicate with them are discussed in Chapter 17. Finally, memory
hierarchy concepts related to the caches and MMU are introduced in Chapter 18.
To guide the reader through this material and to keep in mind the ‘‘forest’’ as we carefully examine
many of the ‘‘trees,’’ accompanying discussion appears in a grey box at the beginning of each chapter to tie
the topics in the chapter to the associated components in the generic computer diagram at the start of this
chapter. At the completion of our journey, we will have covered most of the various modules of the computer
and will have an understanding of the fundamentals that underlie both its function and design.
Earlier, we mentioned that a digital computer manipulates discrete elements of information and
that all information in the computer is represented in binary form. Operands used for calculations may
be expressed in the binary number system or in the decimal system by means of a binary code. The
letters of the alphabet are also converted into a binary code. The purpose of the remainder of this chapter
is to introduce the various number systems especially the binary number systems, binary arithmetic, and
few selected codes as a basis for further study in the succeeding chapters. In relation to the generic
computer, this material is very important and spans all of the components except some in I/O that in-
volve mechanical operations and analog (as contrasted with digital) electronics.
DIGITAL COMPUTERS AND INFORMATION 7

1-2 NUMBER SYSTEMS


The decimal number system is employed in everyday arithmetic to represent numbers by strings of
digits. As the decimal number system is weighted and positional, depending on its position in the string,
each digit has an associated value of an integer raised to the power of 10. For example, the decimal
number 541.46 is interpreted to represent 5 hundreds plus 4 tens plus 1 units plus 4 tenths and 6 hun-
dredths. The hundreds, tens, units, and tenths and hundredths are powers of 10 implied by the position
of the digits. The value of the number is computed as follows:
541.46 = 5 ¥ 102 + 4 ¥ 101 + 1 ¥ 100 + 4 ¥ 10–1 + 6 ¥ 10–2
or 333.33 = 3 ¥ 102 + 3 ¥ 101 + 3 ¥ 100 + 3 ¥ 10– 1 + 3 ¥ 10–2
The convention is to write only the digits and infer the corresponding powers of 10 from their
positions. In general, a decimal number with n digits to the left of the decimal point and m digits to the
right of the decimal point is represented by a string of coefficients:
An-1An-2 ... A1 A0. A- 1A- 2 ... A-m + 1 A-m
Each coefficient Ai is one of the 10 digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9). The subscript value i gives the
position of the coefficient and, hence, the weight 10i by which the coefficient must be multiplied.
The decimal number system is said to be of base or radix 10, because the coefficients are multi-
plied by powers of 10 and the system uses 10 distinct digits. In general, a number in base r contains r
digits, 0, 1, 2, ..., r - 1, and is expressed as a power series in r with the general form
An - 1rn - 1 + An - 2rn - 2 + ... + A1r1 + A0r0 + A–1r-1 + A-2r-2 + ... + A–m + 1r-m + 1 + A-mr-m
When the number is expressed in positional notation, only the coefficients and the radix point are written
down:
An-1 An-2 ... A1A0. A-1 A-2 ... A- m + 1 A-m
In general, the ‘‘.’’ is called the radix point. An - 1 is referred to as the most significant digit (msd), and
A-m is referred to as the least significant digit (1sd) of the number. Note that if m = 0, the 1sd is
A-0 = A0. To distinguish between numbers of different bases, it is customary to enclose the coefficients
in parentheses and place a subscript after the right parenthesis to indicate the base of the number. How-
ever, when the context makes the base obvious, it is not necessary to use parentheses. The following
illustrates a base-5 number with n = 3 and m = 1 and its conversion to decimal:
(414.2)5 = 4 ¥ 52 + 1 ¥ 51 + 4 ¥ 50 + 2 ¥ 5-1
= 100 + 05 + 04 + 0.4 = (109.4)10

ADDITIONAL EXAMPLES ON CONVERSION TO DECIMAL


1. A number in base 5 with n = 4 and m = 3
(3333.333)5 = 3 ¥ 53 + 3 ¥ 52 + 3 ¥ 51 + 3 ¥ 50 + 3 ¥ 5-1 + 3 ¥ 5-2 + 3 ¥ 5-3
= 375 + 75 + 15 + 3 + 0.6 + 0.12 + 0.024 = (468.744)10
2. A number in base 4 with n = 4 and m = 3
(3333.333)4 = 3 ¥ 43 + 3 ¥ 42 + 3 ¥ 41 + 3 ¥ 40 + 3 ¥ 4-1 + 3 ¥ 4-2 + 3 ¥ 4-3
= 192 + 48 + 12 + 3 + 0.75 + 0.1875 + 0.046875 = (255.984375)10
8 LOGIC AND COMPUTER DESIGN FUNDAMENTALS

Note that for all the numbers without the base designated, the arithmetic is performed with decimal
numbers. Note also that the base-5 system uses only five digits, and, therefore, the values of the coeffi-
cients in a number can be only 0, 1, 2, 3, and 4 when expressed in that system and base 4 system uses
only 4 digits, and, therefore, the values of the coefficients in a number can only be 0, 1, 2, 3.
An alternative method for conversion to base 10 that reduces the number of operations is based on
a factored form of the power series:
(...((An - 1 r + An - 2)r + An - 3)r + ... + A1)r + A0
+ (A-1 + (A-2 + (A-3 + ... + (A-m + 2 + (A-m + 1 + A-mr-1) r-1) r-1...)r-1) r-1)r-1
For the example above,
(414.2)5 = ((4 ¥ 5 + 1) ¥ 5) + 4 + 2 ¥ 5-1
= 21 ¥ 5 + 4 + 0.4 = (109.4)10
and
(3333.333)4 = (((3 ¥ 4 + 3) ¥ 4 + 3) ¥ 4) + 3 + 3 ¥ 4-1 + 3 ¥ 4-2 + 3 ¥ 4-3
= ((15 ¥ 4 + 3) ¥ 4) + 3 + 3 ¥ 4-1 + 3 ¥ 4-2 + 3 ¥ 4-3
= (63 ¥ 4) + 3 + 0.75 + 0.1875 + 0.046875
= (255.984375)10
In addition to decimal, three number systems are used in computers: binary, octal, and hexadeci-
mal. These are base-2, base-8, and base-16 number systems, respectively. Sometimes number systems
with a different base may also be used as per the requirement of a particular system.

Binary Numbers

The binary number system is a base-2 system with two digits, 0 and 1. This is also a weighted positional
number system. A binary number such as 11010.11 is expressed with a string of 1’s and 0’s and, possibly,

TABLE 1-1
Powers of Two
n 2n n 2n n 2n
0 1 8 256 16 65,536
1 2 9 512 17 131,072
2 4 10 1,024 18 262,144
3 8 11 2,048 19 524,288
4 16 12 4,096 20 1,048,576
5 32 13 8,192 21 2,097,152
6 64 14 16,384 22 4,194,304
7 128 15 32,768 23 8,388,608

a binary point. The decimal equivalent of a binary number can be found by expanding the number into
a power series with a base of 2. For example,
DIGITAL COMPUTERS AND INFORMATION 9
(11010)2 = 1 ¥ 24 + 1 ¥ 23 + 0 ¥ 22 + 1 ¥ 21 + 0 ¥ 20 = (26)10
0.11 = 1 ¥ 2–1 + 1 ¥ 2–2 = 0.5 + 0.25 = (0.75)10
\ (11010.11)2 = (26.75)10
or (100111.1001)2 = 1 ¥ 25 + 0 ¥ 24 + 0 ¥ 23 + 1 ¥ 22 + 1 ¥ 21 + 1 ¥ 20 + 1 ¥ 2-1
+ 0 ¥ 2-2 + 0 ¥ 2-3 + 1 ¥ 2-4
= 32 + 4 + 2 + 1 + 0.5 + 0.0625
= (39.5625)10
As noted earlier, the digits in a binary number are called bits (binary digit). When a bit is equal to 0, it does
not contribute to the sum during the conversion. Therefore, the conversion to decimal can be obtained by
adding the numbers with powers of two corresponding to the bits that are equal to 1. For example,
(1010101.1010)2 = 64 + 16 + 4 + 1 + 0.5 + 0.125 = (85.625)10
and
(110101.11)2 = 32 + 16 + 4 + 1 + 0.5 + 0.25 = (53.75)10
The group of 4 bits is called nibble and a group of eight bits is called a word or a character. The
first 24 numbers obtained from 2 to the power of n are listed in Table 1-1. In computer work, 210 is
referred to as K (kilo), 220 as M (mega), and 230 as G (giga). Thus,
4K = 22 ¥ 210 = 212 = 4,096 and 16M = 24 ¥ 220 = 224 = 16,777,216
The conversion of a decimal number to binary can be easily achieved by a method that succes-
sively subtracts powers of two from the decimal number. To convert the decimal number N to binary,
first find the greatest number that is a power of two (see Table 1–1) and that, subtracted from N, pro-
duces a positive difference. Let the difference be designated N1. Now find the greatest number that is a
power of two and that, subtracted from N1, produces a positive difference N2. Continue this procedure
until the difference is zero. In this way, the decimal number is converted to its powers-of-two compo-
nents. The equivalent binary number is obtained from the coefficients of a power series that forms the
sum of the components. 1’s appear in the binary number in the positions for which terms appear in the
power series, and 0’s appear in all other positions. This method is demonstrated by the conversion of
decimal 625 to binary as follows:
625 - 512 = 113 = N1 512 = 29
113 - 64 = 49 = N2 64 = 26
49 - 32 = 17 = N3 32 = 25
17 - 16 = 1 = N4 16 = 24
1-1=0 = N5 1 = 20
(625)10 = 29 + 26 + 25 + 24 + 20 = (1001110001)2
Another standard method followed is Double Dabble method of conversion or the method of
repeated division. The steps to be followed are different for the integer part and the fractional part. The
steps for the conversion of the integer portion of the decimal number are:
1. Divide the given decimal number by 2 and note down the quotient and the remainder.
2. Divide the quotient again by 2 setting aside the remainder.
10 LOGIC AND COMPUTER DESIGN FUNDAMENTALS

3. Repeat the step 2 until the quotient is 0, i.e. the quotient is no longer divisible by 2.
4. Equivalent binary number is read from the bottom (this bit becomes MSB), to the top (this bit be-
comes LSB).
For example, to convert (25)10 to binary
2 25
2 12 1 LSB (Least significant bit)
2 06 0
2 03 0
2 01 1
00 1 MSB (Most significant bit)

So (25)10 = (11001)2
The steps for the conversion of the fractional portion of the decimal number are as follows:
1. Multiply the decimal fraction by 2.
2. Record (from the answer obtained in step 1), the number which is just before the decimal point.
3. Multiply the fractional portion of the result by 2 again. Record the integer portion of this product.
4. Continue step 3 until the fractional part of the product is 0 or one has obtained the number to a
required number of decimal precision.
5. Read the integer portions recorded from the top to the bottom.
DIGITAL COMPUTERS AND INFORMATION 11
EXAMPLE 1-1 Conversion of Decimal to Binary
Convert (0.875)10 into binary
(0.875)10 = 0.875 ¥ 2 = 1.75 1
= 0.750 ¥ 2 = 1.5 1
= 0.500 ¥ 2 = 1.0 1
Thus, (0.875)10 = (0.111)2

EXAMPLE 1-2
Convert (85.625)10 to binary
First let us convert the integer portion
2 85
2 42 1 LSB
2 21 0
2 10 1
2 05 0
2 02 1
2 01 0
00 1 MSB
and then the fractional part:
0.625 ¥ 2 = 1.250 1
0.250 ¥ 2 = 0.500 0
0.500 ¥ 2 = 1.000 1
Thus (85.625)10 = (1010101.101)2

ADDITIONAL EXAMPLES ON CONVERSION


1. (1100111.1101)2 = 1 ¥ 26 + 1 ¥ 25 + 0 ¥ 24 + 0 ¥ 23 + 1 ¥ 22 + 1 ¥ 21
+ 1 ¥ 20 + 1 ¥ 2-1 + 1 ¥ 2-2 + 0 ¥ 2-3 + 1 ¥ 2-4
= 64 + 32 + 4 + 2 + 1 + 0.5 + 0.25 + 0.0625
= (103.8125)10
2. (110111)2 = 1 ¥ 25 + 1 ¥ 24 + 0 ¥ 23 + 1 ¥ 22 + 1 ¥ 21 + 1 ¥ 20
= 32 + 16 + 4 + 2 + 1
= (55)10
3. (1100110011)2 = 1 ¥ 2 9 + 1 ¥ 28 + 0 ¥ 2 7 + 0 ¥ 26 + 1 ¥ 2 5 + 1 ¥ 2 4
+ 0 ¥ 23 + 0 ¥ 22 + 1 ¥ 21 + 1 ¥ 20
= 512 + 256 + 32 + 16 + 2 + 1
= (819)10
4. (111000111)2 = 1 ¥ 28 + 1 ¥ 27 + 1 ¥ 26 + 0 ¥ 25 + 0 ¥ 24 + 0 ¥ 23
+ 1 ¥ 22 + 1 ¥ 21 + 1 ¥ 20
= 256 + 128 + 64 + 4 + 2 + 1
= (455)10
12 LOGIC AND COMPUTER DESIGN FUNDAMENTALS

5. (1001011)2 = 1 ¥ 26 + 0 ¥ 25 + 0 ¥ 24 + 1 ¥ 23 + 0 ¥ 22 + 1 ¥ 21 + 1 ¥ 20
= 64 + 8 + 2 + 1
= (75)10
6. (51)10 = (110011)2
2 51
2 25 1 LSB
2 12 1
2 06 0
2 03 0
2 01 1
00 1 MSB
7. (35.32)10 = (100011.0101)2
2 35
2 17 1 LSB
2 08 1
2 04 0
2 02 0
2 01 0
00 1 MSB
0.32 ¥ 2 = 0.64 0
0.64 ¥ 2 = 1.28 1
0.28 ¥ 2 = 0.56 0
0.56 ¥ 2 = 1.12 1
0.12 ¥ 2 = 0.24 0
0.24 ¥ 2 = 0.48 0
The calculation can extend to as many decimal places as required, but most often, one can stop after
calculating up to 4th decimal place.
So (35.32)10 = (100011.010100...)2
8. (111.10)10 = (1101111.00011)2
2 111
2 55 1 LSB
2 27 1
2 13 1
2 06 1
2 03 0
2 01 1
00 1 MSB
DIGITAL COMPUTERS AND INFORMATION 13

0.10 ¥ 2 = 0.20 0
0.20 ¥ 2 = 0.40 0
0.40 ¥ 2 = 0.80 0
0.80 ¥ 2 = 1.60 1
0.60 ¥ 2 = 1.20 1
9. (48.125)10 = (110000.001)2 (Verify!)
10. (3245.789)10 = (110010101101.11001010...)2 (Verify!)

Octal and Hexadecimal Numbers

As previously mentioned, all computers and digital systems use the binary representation. The octal
(base-8) and hexadecimal (base-16) systems are useful for representing binary quantities indirectly be-
cause they possess the property that their bases are powers of two. Since 23 = 8 and 24 = 16, each octal
digit corresponds to three binary digits and each hexadecimal digit corresponds to four binary digits.
The more compact representation of binary numbers in either octal or hexadecimal is much more
convenient for people than using bit strings in binary that are three to four times as long. Thus, most
computer manuals use either octal or hexadecimal numbers to specify binary quantities. A group of 15
bits, for example, can be represented in the octal system with only five digits. A group of 16 bits can be
represented in hexadecimal with four digits. The choice between an octal and a hexadecimal representa-
tion of binary numbers is arbitrary, although hexadecimal tends to win out, since bits often appear in a
group of size divisible by four.
The octal number system is the base-8 system with digits 0, 1, 2, 3, 4, 5, 6, 7. An example of an
octal number is 367.54. To determine its equivalent decimal value, we expand the number in a power
series with a base of 8:
(367.54)8 = 3 ¥ 82 + 6 ¥ 81 + 7 ¥ 80 + 5 ¥ 8-1 + 4 ¥ 8-2 = (247.6875)10
(236.2)8 = 2 ¥ 82 + 3 ¥ 81 + 6 ¥ 80 + 2 ¥ 8-1 = (158.25)10
(2765.012)8 = 2 ¥ 83 + 7 ¥ 82 + 6 ¥ 81 + 5 ¥ 80 + 0 ¥ 8-1+ 1 ¥ 8-2+ 2 ¥ 8-3 = (1525.01953125)10
Note that the digits 8 and 9 cannot appear in an octal number.
It is customary to use the first r digits from the decimal system, starting with 0, to represent the
coefficients in a base-r system when r is less than 10. The letters of the alphabet are used to supplement
the digits when r is 10 or more. The hexadecimal number system is a base-16 system with the first 10
digits borrowed from the decimal system and the letters A, B, C, D, E, and F used for the values 10, 11,
12, 13, 14, and 15, respectively. An example of a hexadecimal number is
(B65F)16 = B ¥ 163 + 6 ¥ 162 + 5 ¥ 161 + F ¥ 160 = (46687)10 (Note: B = 11, F = 15)
(ABCD)16 = A ¥ 163 + B ¥ 162 + C ¥ 161 + D ¥ 160 = (43981)10
(BAD)16 = B ¥ 162 + A ¥ 161 + D ¥ 160 = (2989)10
The first 16 numbers in the decimal, binary, octal, and hexadecimal number systems are listed in
Table 1-2. Note that the sequence of binary numbers follows a prescribed pattern.
14 LOGIC AND COMPUTER DESIGN FUNDAMENTALS

Binary to Octal Conversion The conversion from binary to octal is easily accomplished by parti-
tioning the binary number into groups of 3 bits each, starting from the binary point and proceeding to the
left and to the right. The corresponding octal digit is then assigned to each group. The following ex-
ample illustrates the procedure:
(100 111 101 101.000 000 110)2 = (4755.006)8

TABLE 1-2
Numbers with Different Bases
Decimal Binary Octal Hexadecimal
(base 10) (base 2) (base 8) (base 16)
0 0000 00 0
1 0001 01 1
2 0010 02 2
3 0011 03 3
4 0100 04 4
5 0101 05 5
6 0110 06 6
7 0111 07 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F

Note that if the leftmost group and the rightmost group do not contain 3 bits, 0s can be added on the left
of the string of bits to the left of the binary point. More importantly, 0s must be added on the right of the
string of bits to the right of the binary point to make the number of bits a multiple of three and obtain the
correct octal result.
So,
(010 100 111.110 110 100)2 = (247.664)8 and not (247.661)8 (Two zeros added to the
(010 110 001 101 011. 111 100 000 110)2 = (26153.7406)8 right of binary point and
(010 101 101.011 010)2 = (255.32)8 one to the left)
The corresponding octal digit for each group of three bits is obtained from the first eight entries in
Table 1-2.
Conversion from Binary to Hexadecimal Conversion from binary to hexadecimal is similar,
except that the binary number is divided into groups of four digits. The binary numbers are converted to
hexadecimal as follows:
(1010 0111.1101 1010)2 = (A7.DA)16
DIGITAL COMPUTERS AND INFORMATION 15
(1 1000 0111 1001.1010 101)2 = (1879.AA)16
(0010 1100 0110 1011. 1111 0000 0110)2 = (2C6B.F06)16
(10 1101 1011.1101 1)2 = (2DB.D8)16
The corresponding hexadecimal digit for each group of four bits is obtained by reference to Table 1-2.
Conversion to Binary from Octal or Hexadecimal Conversion from octal or hexadecimal to
binary is done by reversing the procedure just performed. Each octal digit is converted to a 3-bit binary
equivalent and extra 0’s (to the extreme left or extreme right) are ignored. Similarly, each hexadecimal
digit is converted to its 4-bit binary equivalent. This is illustrated in the following examples:
(673.12)8 = 110 111 011. 001 010 = (110111011.00101)2
(573)8 = (101 111 011)2
(85A)16 = (1000 0101 1010)2
(3A6.C)16 = 0011 1010 0110. 1100 = (1110100110.11)2
Conversion from Decimal to Octal and Hexadecimal To convert from decimal to octal one
can follow double dabble method as described earlier. However, to convert to octal, the integer portion
has to be divided successively by 8 and to convert the fractional portion of the number, the fractional
part of the number and later the products have to be successively multiplied by 8.
To convert to hexadecimal, the integer portion has to be divided successively by 16 and to convert
the fractional portion of the number, the fractional part of the number and later the products have to be
successively multiplied by 16.

EXAMPLE 1-3 Conversion of Decimal to Octal


(247.6875)10 = (?)8
8 247
8 30 7 LSD
8 03 6
00 3 MSD
0.6875 ¥ 8 = 5.5 5
0.5 ¥ 8 = 4.0 4
Thus, (247.6875)10 = (367.54)8

EXAMPLE 1-4 Conversion of Decimal to Hexadecimal


(1111.10)10 = (?)16
16 1111
16 0069 7 LSD
16 004 5
00 4 MSD
0.10 ¥ 16 = 1.6 1
0.60 ¥ 16 = 9.6 9
0.60 ¥ 16 = 9.6 9
0.60 ¥ 16 = 9.6 9
Thus, (1111.10)10 = (457.1999)16
16 LOGIC AND COMPUTER DESIGN FUNDAMENTALS

Conversion between Bases

General rules:
1. Integers and fractions are converted separately.
2. The integer portion is converted using repeated division by the new base (r) and using the
sequence of remainders generated to create the new number. The remainders are read from bot-
tom up to obtain the number in the required number system. Arithmetic is done in old base. If the
conversion is from a decimal number to an octal number (r = 8), the successive division is by 8. If
r = 16, the successive division is by 16.
3. The fractional part is converted by repeated multiplication by new base, using the generated
integers to represent the converted fraction. Arithmetic is done in old base. If the conversion is
from a decimal number to an octal number (r = 8), the successive multiplication is by 8. If r = 16,
the successive multiplication is by 16.
Note: In the examples discussed earlier, the old base is 10 since we are converting the decimal
numbers.

Number Ranges

In digital computers, the range of numbers that can be represented is based on the number of bits avail-
able in the hardware structures that store and process information. The number of bits in these structures
is most frequently a power of two, such as 8, 16, 32, and 64. Since the numbers of bits is fixed by the
structures, the addition of leading or trailing zeros to represent numbers is necessary, and the range of
numbers that can be represented is also fixed.
For example, for a computer processing 16-bit unsigned integers, the number 537 is represented
as 0000001000011001. The range of integers that can be handled by this representation is from 0 to
216 - 1, that is, from 0 to 65,535. If the same computer is processing 16-bit unsigned fractions with the
binary point to the left of the most significant digit, then the number 0.375 is represented by
0.0110000000000000. The range of fractions that can be represented is from 0 to (216 – 1)/216, or from
0.0 to 0.9999847412.
In later chapters, we will deal with fixed-bit representations and ranges for binary signed numbers
and floating-point numbers. In both of these cases, some bits are used to represent information other
than simple integer or fraction values.

1-3 ARITHMETIC OPERATIONS


Arithmetic operations with numbers in base r follow the same rules as for decimal numbers. However,
when a base other than the familiar base 10 is used, one must be careful to use only r allowable digits
and perform all computations with base-r digits.
DIGITAL COMPUTERS AND INFORMATION 17
Binary Addition

Rules for binary addition:


0+0=0
0+1=1
1+0=1
1 + 1 = 0 with a carry of 1.
In a tabular form
Augend Addend Sum Carry Result
0 0 0 0 0
0 1 1 0 1
1 0 1 0 1
1 1 0 1 10

EXAMPLE 1-5 Binary Addition


Perform (10)10 + (5)10 using rules of binary addition
(10)10 = (1010)2 and (5)10 = (0101)2. So, the operation is:
Carry 0000
Augend 1010
+ Addend 0101
Sum 1111 (=15)10

EXAMPLE 1-6
Perform (27)10 + (13)10 using rules of binary addition
(27)10 = (11011)2 and (13)10 = (1101)2
So, the operation is
Carry 11111
Augend 11011
+ Addend 01101
Sum 101000 (= 40)10

ADDITIONAL EXAMPLES ON BINARY ADDITION


1. (22)10 + (13)10 = (010110)2 + (001101)2 = (100011)2 = (35)10
2. (75)10 + (25)10 = (1001011)2 + (11001)2 = (1100100)2 = (100)10
3. (110110)2 + (111)2 = (111101)2
4. (101101)2 + (101100)2 = (1011001)2
5. (1110111)2 + (1001001)2 = (11000000)2
18 LOGIC AND COMPUTER DESIGN FUNDAMENTALS

Binary Subtraction

The following are the rules of binary subtraction:


0-0=0
0 - 1 = 1 with borrow 1
1-0=1
1-1=0
or, in the tabular form it is:
Minuend Subtrahend Difference Borrow

0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0

The following are examples of the subtraction of two binary numbers; as with addition, note the names
of the operands:

EXAMPLE 1-7 Binary Subtraction


Borrows: 00000 00110 00110
Minuend: 10110 10110 10011 **
Subtrahend: - 10010 - 10011 - 11110 **
Difference: 00100 00011 - 01011
The rules for subtraction are the same as in decimal, except that a borrow into a given column adds 2 to
the minuend bit. (A borrow in the decimal system adds 10 to the minuend digit.) Recall that, in the event
that the subtrahend is larger than the minuend, we subtract the minuend from the subtrahend and give
the result a minus sign.

ADDITIONAL EXAMPLES ON BINARY SUBTRACTION


1. (23)10 - (17)10
(23)10 = (10111)2 and 17 = (10001)2
So, the operation will be
Borrow 00000
Minuend 10111
- Subtrahend 10001
Result 00110 (= 610)
2. (17)10 - (15)10
(17)10 = (10001)2 and (15)10 = (1111)2
DIGITAL COMPUTERS AND INFORMATION 19

So, the operation will be


Borrow 1110
Minuend 10001
- Subtrahend 1111
Result 00010 (= 210)
3. (1100110)2 - (1010111)2 = (1111)2
4. (1111)2 - (10101)2 = – (0110)2
5. (11001100)2 - (101010)2 = (10100010)2

Binary Multiplication
The next operation to be illustrated is binary multiplication, which is quite simple. The multiplier digits
are always 1 or 0. Therefore, the partial products are equal either to the multiplicand or to 0. Multiplica-
tion is illustrated by the following example:

EXAMPLE 1-8 Binary Multiplication


Multiplicand: 1011
Multiplier: ¥ 101
1011
00000
101100
Product: 110111
and multiplication of (10101)2 ¥ (110)2 will be
Multiplicand: 10101
Multiplier: ¥ 110
00000
101010
1010100
Product: 1111110

ADDITIONAL EXAMPLES ON BINARY MULTIPLICATION


1. (1110101)2 ¥ (1010)2 = (10010010010)2
2. (101)2 ¥ (11110)2 = (10010110)2
3. (10111010101)2 ¥ (110)2 = (10001011111110)2
4. (11110101)2 ¥ (10110)2 = (1010100001110)2
5. (10101)2 ¥ (11000)2 = (111111000)2
Note: The binary multiplication can be achieved by shifting a bit to left (why?).

Binary Division
The final operation of binary division is again simple as the quotient can be a 1 or a 0. The operation of
division is illustrated with the following example:
20 LOGIC AND COMPUTER DESIGN FUNDAMENTALS

EXAMPLE 1-9 Binary Division


(10101)2 ÷ (101)2

Thus, (10101)2 ÷ (101)2 = (100)2 Remainder 1

EXAMPLE 1-10
(100100)2 ÷ (11)2

Thus, (100100)2 ÷ (11)2 = (1100)2 Remainder 0.


Note: The operation of binary division can be achieved by shifting a bit to right. (Why?)
Arithmetic operations with octal, hexadecimal, or any other base-r system will require the formu-
lation of tables from which one obtains sums and products of two digits in that base. An easier alterna-
tive for adding two numbers in base r is to convert each pair of digits in a column to decimal, add the
digits in decimal, and then convert the result to the corresponding sum and carry in the base-r system.
Since addition is done in decimal, we can rely on our memories for obtaining the entries from the
familiar decimal addition table. The sequence of steps for adding the two octal numbers 346 and 255 is
shown in Example 1-11.

EXAMPLE 1-11 Octal Addition


(346)8 + (255)8
Carry: 1 1
346 3 4 6
+ 255 2 5 5
6 2(10 - 8) 3(11 - 8)
So, (346)8 + (255)8 = (623)8

ADDITIONAL EXAMPLES ON OCTAL ADDITION


1. (456)8 + (273)8
Carry: 1 1
4 5 6
2 7 3
7 5(13 - 8) 1(9 - 8)
So, (456)8 + (273)3 = (751)8
DIGITAL COMPUTERS AND INFORMATION 21
2. (624)8 + (154)8
Carry: 1 1 1 0
6 2 4
1 5 4
1 0(8 - 8) 0(8 - 8) 0(8 - 8)
Thus, (624)8 + (154)3 = (1000)8.

Tables 1.3(a) and (b) give addition and multiplication tables for octal number, respectively and Tables
1.4 (a) and (b) give addition and multiplication tables for hexadecimal numbers, respectively.
The multiplication of two base-r numbers can be accomplished by doing all the arithmetic opera-
tions in decimal and converting intermediate results one at a time. This is illustrated in the multiplication
of two octal numbers shown in Example 1-13.

EXAMPLE 1-12 Hexadecimal Addition


(340)16 + (AE3)16.
Hexadecimal Equivalent Decimal Calculation
Carry: 1 0
346 3 4 6
+ AE3 10 14 3
14 2 9
So, (346)16 + (AE 3)16 = (E29)16
The equivalent decimal calculation columns on the right show the mental reasoning that must be carried
out to produce each digit of the hexadecimal sum. The sum of 6 and 3 is 9 is a valid hexadecimal
number. However, 4 + E(14) = 18 is not a valid hexadecimal number. To convert it back to hexadecimal,
subtract 16 from the result and carry over the 1 for further addition. Now, 3 + A (10) + 1(Carry) = 14
which is E in hexadecimal. So, the result is, (E29)16.

ADDITIONAL EXAMPLES ON HEXADECIMAL ADDITION


1. Carry: 1 1 1
BAD 11 10 13
+ DAD 13 10 13
1 9(25 - 16) 5(21 - 16) 10(26 - 16)
Thus, (BAD)16 + (DAD)16 = (195 A)16.
2. BEBE
+ FACE
Carry: 1 1 1 1
11 14 11 14
15 10 12 14
1 11 (27 - 16) 9(25 - 16) 8(24 - 16) 12(28 - 16)
So, (BEBE)16 + (FACE)16 = (1B98C)16.
22 LOGIC AND COMPUTER DESIGN FUNDAMENTALS

EXAMPLE 1-13 Octal Multiplication


(725)8 ¥ (33)8
7 2 5
¥ 3 3
2 5(21 - 16) 7(6 + 1) 7(15 - 8)
2 5(21 - 16) 7(6 + 1) 7(15 - 8) ¥
3(2 + 1) 0(7 + 1 - 8) 5(12 + 1- 8) 6(14 - 8) 7
Thus, (725)8 ¥ (33)8 = (30567)8.
The figures in the bracket indicate the mental calculation done in decimals.

ADDITIONAL EXAMPLES ON OCTAL MULTIPLICATION


1. (42.4)8 ¥ (37.2)8
4 2 4
¥ 3 7 2
1(+1) 0(8 - 8) 5(4 + 1) 0(8 - 8)
3 6(28 + 2 - 24) 1(14 + 3 - 16) 4(28 - 24) ¥
1 4(12 – 8) 7(6 + 1) 4(12 - 8) ¥ ¥
2(+1) 0(8 - 8) 6(14 - 8) 6(6 + 1) 1(9 - 8) 0
Thus, (42.4)8 ¥ (37.2)8 = (2066.10)8.
2. (274.5)8 ¥ (677)8.
2 7 4 5
¥ 6 7 7
1 4 5 0 3
1 4 5 0 3 ¥
2 1 5 3 6 ¥ ¥
2 3 3 5 3 3. 3
(274.5)8 ¥ (677)8 = (233533.3)8.

TABLE 1-3 (a)


Octal Addition Table
0 1 2 3 4 5 6 7
0 0 1 2 3 4 5 6 7
1 1 2 3 4 5 6 7 10
2 2 3 4 5 6 7 10 11
3 3 4 5 6 7 10 11 12
4 4 5 6 7 10 11 12 13
5 5 6 7 10 11 12 13 14
6 6 7 10 11 12 13 14 15
7 7 10 11 12 13 14 15 16
DIGITAL COMPUTERS AND INFORMATION 23
TABLE 1-3(b)
Octal Multiplication Table
0 1 2 3 4 5 6 7
0 0 0 0 0 0 0 0 0
1 0 1 2 3 4 5 6 7
2 0 2 4 6 10 12 14 16
3 0 3 6 11 14 17 22 25
4 0 4 10 14 20 24 30 34
5 0 5 12 17 24 31 36 43
6 0 6 14 22 30 36 44 52
7 0 7 16 25 34 43 52 61

TABLE 1-4(a)
Hexadecimal Addition Table
0 1 2 3 4 5 6 7 8 9 A B C D E F
0 0 1 2 3 4 5 6 7 8 9 A B C D E F
1 1 2 3 4 5 6 7 8 9 A B C D E F 10
2 2 3 4 5 6 7 8 9 A B C D E F 10 11
3 3 4 5 6 7 8 9 A B C D E F 10 11 12
4 4 5 6 7 8 9 A B C D E F 10 11 12 13
5 5 6 7 8 9 A B C D E F 10 11 12 13 14
6 6 7 8 9 A B C D E F 10 11 12 13 14 15
7 7 8 9 A B C D E F 10 11 12 13 14 15 16
8 8 9 A B C D E F 10 11 12 13 14 15 16 17
9 9 A B C D E F 10 11 12 13 14 15 16 17 18
A A B C D E F 10 11 12 13 14 15 16 17 18 19
B B C D E F 10 11 12 13 14 15 16 17 18 19 1A
C C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B
D D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C
E E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D
F F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E

EXAMPLE 1-14 Hexadecimal Multiplication


(73A)16 ¥ (2D)16.
7 3 A(10)
¥ 2 D(13)
5 D(91 + 2- 80) F(39 + 8 - 32) 2(130 - 128)
E 7(6 + 1) 4(20 - 16) ¥
1 4(19 + 1 - 16) 5(20 + 1 - 16) 3(19 - 16) 2
Thus, (73A)16 ¥ (2D)16 = (14532)16.
24 LOGIC AND COMPUTER DESIGN FUNDAMENTALS

TABLE 1-4(b)
Hexadecimal Multiplication Table
0 1 2 3 4 5 6 7 8 9 A B C D E F
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 1 2 3 4 5 6 7 8 9 A B C D E F
2 0 2 4 6 8 A C E 10 12 14 16 18 1A 1C 1E
3 0 3 6 9 C F 12 15 18 1B 1E 21 24 27 2A 2D
4 0 4 8 C 10 14 18 1C 20 24 28 2C 30 34 38 3C
5 0 5 A F 14 19 1E 23 28 2D 32 37 3C 41 46 4B
6 0 6 C 12 18 1E 24 2A 30 36 3C 42 48 4E 54 5A
7 0 7 E 15 1C 23 2A 31 38 3F 46 4D 54 5B 62 69
8 8 10 18 20 28 30 38 40 48 50 58 60 68 70 78
9 0 9 12 1B 24 2D 36 3F 48 51 5A 63 6C 75 7E 87
A 0 A 14 1E 28 32 3C 46 50 5A 64 6E 78 82 8C 96
B 0 B 16 21 2C 37 42 4D 58 63 6E 79 84 8F 9A A5
C 0 C 18 24 30 3C 48 54 60 6C 78 84 90 9C A8 B4
D 0 D 1A 27 34 41 4E 5B 68 75 82 8F 9C A9 B6 C3
E 0 E 1C 2A 38 46 54 62 70 7E 8C 9A A8 B6 C4 D2
F 0 F 1E 2D 3C 4B 5A 69 78 87 96 A5 B4 C3 D2 E1

Similar tables can be constructed for any base to simplify the calculations.
Hexadecimal Multiplication: The key thing to remember is to ensure that the mental multiplication is
to be done in decimal.

ADDITIONAL EXAMPLE ON HEXADECIMAL MULTIPLICATION


1. (ABC)16 ¥ (25)16
A(10) B(11) C(12)
¥ 2 5
3 5(50 + 3- 48) A(55 + 3 – 48) C(60 - 48)
1 5(20 + 1 - 16) 7(22 + 1 - 16) 8(24 – 16) ¥
1 8 D(12 + 1) 2(18 – 16) C
Thus, (ABC)16 ¥ (25)16 = (18D2C)16.

Floating Point Numbers


The systems we have defined so far are fixed base r systems. This means that the number of decimal
points that will be used will be fixed and cannot be varied by the user. However, if the number of bits
required to represent the integer part of the number is more than the defined number of bits, it is difficult
to represent it. In this case, a scientific notation of mantissa and exponent can be used. The floating point
format for a number N in general is
N = M ¥ 10E where M is the mantissa and E is the exponent.
The decimal number here is said to be floating as we can change the value of the exponent depending on
the number of bits available for the representation. So,
DIGITAL COMPUTERS AND INFORMATION 25
1234.1234 can be represented as 123.41234 ¥ 101
or 12.341234 ¥ 102
or 1.2341234 ¥ 103
or 1234123.4 ¥ 10-3
or 12341234 ¥ 10-4
As in the case of decimal numbers, binary numbers can be represented in a scientific notation as follows:
N = M ¥ 2E where M is the mantissa and E is the exponent.
There are many ways of arranging the format in a digital computer. A single bit is reserved for the sign,
some bits for the mantissa and some for the exponent. In a 32-bit system, starting from MSB, bit 1 is a
sign bit, the next 8 bits are for the exponent and the remaining 23 for the mantissa. In a 32-bit format the
exponent can be - 128 to +127.

S Exponent Mantissa
0 1 9 10 31
In a 64-bit machine, MSB is reserved for the sign bit, 2 to 12 are for the exponent and the rest 52
are for mantissa. This is the IEEE (Institution of Electrical and Electronics Engineers) format. So, the
value of the exponent can be - 1024 to + 1023.
When we represent the mantissa as 1M. ¥ 2E it said to be in normalized form, i.e. 1.001 ¥ 22 is in
normalized form but 10.01 ¥ 21 is not.
For a 32-bit single precision number, the number represented in normalized floating point repre-
sentation is ± 1M. 2E-127 and for a 64-bit double precision representation it is ± 1M. 2E-1023

Representation of Signed Binary Numbers

An n-bit signed binary number is represented in two parts, a sign part and a magnitude part. The first bit
of a number is the sign bit denoting the sign of the number and the rest (n - 1) are the magnitude bits
representing the magnitude of the number. Conventionally, a 0 in the sign bit position represents a
positive number and a 1 in the sign bit position represents a negative number. There are various methods
of representing signed numbers, the three most popular schemes being the following:
1. Sign magnitude scheme.
2. 1’s complement scheme.
3. 2’s complement scheme.

0 ........... 1 ...........

Positive Magnitude Negative Magnitude


sign sign

The arithmetic in each of these schemes is different as the form for the magnitude part in each of
the schemes is different.
Note: The positive numbers in all three schemes are represented in the same way. It is only the
representation of negative numbers that varies with the scheme. For example a + 13 is represented as
01101 in sign magnitude, 1’s complement and 2’s complement scheme.
26 LOGIC AND COMPUTER DESIGN FUNDAMENTALS

Sign Magnitude Scheme

In the sign magnitude scheme, the n-bit number representation requires n + 1 bits. The most significant bit
represents the sign of the number a 0 represents a positive number and a 1 represents a negative number.
The magnitude portion of both the negative numbers and the positive numbers is the same. So, a +13 is
represented as 01101 and a - 13 is represented as 11101, the difference being only in the sign bit position.
A +17 is represented as 010001 and a - 17 is represented as 110001.
The range of numbers that can be represented by an n-bit number using sign magnitude scheme is
+ (2n-1 - 1) to - (2n-1 - 1) i.e., the range of numbers that can be represented by 8 bit is - 27 to 27 i.e., –
127 to +127. Note that there is - 0 (10000) and a + 0 (00000) in this scheme of numbers.
Addition of Two Numbers There are two cases for addition of two numbers.
Case 1: A and B have the same sign
Rules: When A and B have the same sign, an adder adds the magnitude bits using rules of binary addition
and makes the sign bit agree with that of the numbers. Let us illustrate this with the help of an example.

EXAMPLE 1-15 Sign Magnitude Scheme


Let A = +13 and B = +17 then magnitude of A, that is ΩAΩ = 1101 and that of ΩBΩ= 10001. First
step is to make the number of bits in both the numbers same by adding 0’s to the left of the number. Do
not forget that the sign bit has to be the most significant bit, that is the leftmost bit, so the 0’s to be added
should be between the leftmost sign bit and the magnitude of the number.
Now ΩAΩ + ΩBΩ is 01101
+ 10001
11110
The result will thus be 011110 which is + 30 as both the numbers are positive.
Let A = - 13 and B = - 17 then magnitude of A, that is ΩAΩ = 1101 and that of ΩBΩ= 10001.
NowΩAΩ + ΩBΩ is 01101
+ 10001
11110
The result will thus be 111110 which is - 30 as both the numbers are negative.
Case 2: A and B have different signs
Rules: When A and B have different sign, one of the numbers (either A or B) is complemented (a 1 is
changed to a 0 and a 0 is changed to a 1) before addition. After the complement is taken, the magnitude
of the uncomplemented number is added to this complement.
(a) If an overflow occurs, called an END Around Carry (EAC), it is added to the least significant bit
of the sum, and the sign of the sum will be the same as the sign of the number that was not
complemented.
(b) If there is no EAC, the sum is complemented and the sign bit of the sum will be the same as that
of the number that was complemented.
Make sure that before you start solving the sum, the number of magnitude bits in both the numbers
are same (by adding 0’s to the left of the number).
Let us illustrate this with an example.
Let A = -13 and B = +17. First step is to make the number of bits in magnitude part of both the
numbers same by adding 0’s to the left of the number.
DIGITAL COMPUTERS AND INFORMATION 27
Then magnitude of A, that is ΩAΩ = 01101 and that of ΩBΩ= 10001 and ΩAΩ¢ = 10010 and that of
ΩBΩ¢= 01110.
Now ΩAΩ¢ + ΩB Ω is 10010
+ 10001
100011
1 (Add the EAC)
00100
Since there is an EAC, the sign bit of the sum is same as that of the number that was not
complemented. Thus, the result will be 0 00100 which is +4.
Now suppose we do the reverse, that is
ΩAΩ + ΩBΩ¢ is 01101
+ 01110
11011 (No EAC)
Since there is no EAC, the result is complemented 00100 and the sign bit of the sum is same as that of
the number that was complemented. Thus the result will thus be 0 00100 which is +4.
2. Let A = +13 and B = -17. First step is to make the number of bits in magnitude part of both the
numbers same by adding 0’s to the left of the number.
Then magnitude of A, that is ΩAΩ = 01101 and that of ΩBΩ= 10001
and ΩAΩ¢ = 10010 and that of ΩBΩ¢ = 01110.
Now ΩAΩ¢ + ΩBΩ is 10010
+ 10001
100011
1 (Add the EAC)
00100
Since there is an EAC, the sum is in binary form and the sign bit of the sum is same as that of the number
that was not complemented. Thus the result will be 1 00100 which is - 4.
Now suppose we do the reverse, that is complement B(-17)
ΩAΩ + ΩBΩ¢ is 01101
+ 01110
11011 (No EAC)
Since there is no EAC, the result is complemented (00100) to get the sum and the sign bit of the
sum is same as that of the number that was complemented. Thus the result will be 1 00100 which
is -4.

EXAMPLE 1-16
Perform the following operation for A = 64 and B = 31
a) A + B b) – A – B c) A – B d) B – A
Magnitude of ΩAΩ = 1000000 and that of ΩBΩ= 0011111 and
Thus ΩAΩ¢ = 0111111 and ΩBΩ¢ = 1100000

(a) A + B 1000000
64 + 31 + 0011111
1011111 ( = +95 as the sign bit to be added is 0)
28 LOGIC AND COMPUTER DESIGN FUNDAMENTALS

(b) - A - B 1000000
– 64 – 31 + 0011111
1011111 ( = -95 as the sign bit to be added is 1)
(c) A - B 1000000
64 – 31 + 1100000
10100000
1 (Add the EAC)
0100001 ( = +33 as the sign bit is that of the number that is not
complemented, which is 0)
(d) - A + B 0111111
– 64 + 31 + 0011111
1011110 (No EAC)
Since there is no EAC, the result is complemented (0100001) to get the sum and the sign bit of the sum
is same as that of the number that was complemented. Thus, the result will be 1 0100001, which is - 33.

1’s Complement Scheme

This is the second scheme used to represent signed numbers. In this scheme, positive numbers in the 1’s
complement scheme are represented in the same way as the sign magnitude scheme, that is the MSB (0)
represents the sign of the number (+) and the rest of the (n - 1) bits represent the magnitude. The way
negative numbers are represented differs. Each of the bit in the 1’s complement form is a complement
(i.e., 0 is changed to a 1 and a 1 is changed to a 0) of the bits in the magnitude portion of the positive
number. So, a + 13 is represented as 01101 and a - 13 is represented as 10010, and a +17 is represented
as 010001 and a - 17 is represented as 101110. The extra bit in the MSB position is the sign bit indicat-
ing if the number is positive (0) or negative (1).
The range of numbers that can be represented by an n bit number using 1’s complement scheme is
+ (2n-1 - 1) to - (2n-1 - 1), that is the range of numbers that can be represented by 8 bit is - 27 to 27, that
is – 127 to + 127. Note that there is - 0 (11111) and a + 0 (00000) in this scheme of numbers.

Addition of Two Numbers

The main difference between addition of two numbers in sign magnitude system and 1’s complement
system is that the sign bits are also considered .
Case I: When both the numbers A and B are positive
Rule: Add the signed numbers using rules of binary addition. Note now the magnitude as well as the
sign bits are to be added. If the sign bit in the sum is 0 the result is positive. If the sign bit is 1, it indicates
an overflow. An overflow occurs when the sum requires more number of bits to represent than the
number of bits required by the original number.
DIGITAL COMPUTERS AND INFORMATION 29
EXAMPLE 1-17 1’s Complement Addition
Let A = +13 and B = +17 then magnitude of A, is ΩAΩ = 1101 and of ΩBΩ= 10001. First step is make
the number of bits in both the numbers same by adding 0’s to the left of the number. Do not forget that
the sign bit has to be the most significant bit, that is the leftmost bit, so the 0’s to be added should be
between the leftmost sign bit and the magnitude of the number.
Now ΩAΩ + ΩBΩ is 001101
+ 010001
011110
The result will thus be 011110 which is +30 as the sign bit is 0 indicating a positive result.
Let A = +17 and B = +17 then magnitude of A, is ΩAΩ = 010001 and that of ΩBΩ= 010001.
17 + 17 is 34. In 1’s complement scheme, we require minimum 7 bits to represent this number (6 for the
magnitude and 1 for the sign). So it is not possible to represent the sum in 6 bits.
NowΩAΩ + ΩBΩ is 010001
+ 010001
100010
The result will thus be 100010. The sign bit is 1 which indicates that there is an overflow as expected.
Case 2: When both the numbers A and B are negative
Rule: Add the signed numbers, magnitude and the sign bits using the rules for binary addition.
Note that in this case an end around carry will always be generated, both the sign bits being 1. This
carry is added to the least significant bit.
i. If the sign bit of the resulting number is 1, it indicates that the answer is within the range and in 1’s
complement form.
ii. If the sign bit of the resulting number is 0, the answer is outside the range of numbers represent-
able with those many number of bits and hence indicates an overflow.
Let us illustrate this with the help of examples.
1. Let A = –13 and B = –17
ΩAΩ¢ = 110010 and that of ΩBΩ¢ = 101110. Note that this is the way in which negative numbers are
represented in 1’s complement scheme.
Now A + B is 110010
+ 101110
1100000
1 (Add the EAC)
100001
Since the sign bit in the result 1, the sum is in 1’s complement form and in the range. Thus the result is
100001 which is –30 in 1’s complement form.
2. Let A = –17 and B = -17
ΩAΩ¢ = 101110 and that of ΩBΩ¢ = 101110. Note that this is the way in which negative numbers are
represented in 1’s complement scheme.
Now A + B is 101110
+ 101110
1011100
1 (Add the EAC)
011101

Vous aimerez peut-être aussi