0% found this document useful (0 votes)
17 views103 pages

UNIT - I Part-1

Uploaded by

chvinayaka5895
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views103 pages

UNIT - I Part-1

Uploaded by

chvinayaka5895
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 103

UNIT - I

NUMBER SYSTEMS & CODES

Introduction to number systems, Complement


representation of negative numbers, binary
arithmetic, binary codes, Error detecting &
correcting codes
Unit – I

Part – I
Introduction to number systems,
Complement representation of negative
numbers, binary arithmetic

3/25/2023 2
NUMBER SYSTEMS & CODES
Positional Number Systems

The traditional number system that we learned in school and


use every day in business is called a positional number
system. In such a system, a number is represented by a
string of digits, where each digit position has an associated
weight. The value of a number is a weighted sum of the
digits. In the decimal number system each of the ten digits, 0
through 9, represents a certain quantity. As you know, the
ten symbols (digits) do not limit you to expressing only ten
different quantities because you use the various digits in
appropriate positions within a number to indicate the
magnitude of the quantity.
3/25/2023 3
You can express quantities up through nine before running
out of digits; if you wish to express a quantity greater than
nine, you use two or more digits, and the position of each
digit within the number tells you the magnitude it represents.

The position of each digit in a decimal number indicates the


magnitude of the quantity represented and can be assigned
a weight. The weights for whole numbers are positive
powers of ten that increase from right to left, beginning with
𝟏𝟎𝟎 = 1.
3/25/2023 4
For fractional numbers, the weights are negative powers of
ten that decrease from left to right beginning with 𝟏𝟎−𝟏

3/25/2023 5
BINARY NUMBERS

The binary number system is another way to represent


quantities. It is less complicated than the decimal system
because the binary system has only two digits. The decimal
system with its ten digits is a base-ten system; the binary
system with its two digits is a base-two system.
The two binary digits (bits) are 1 and 0. The position of a 1
or 0 in a binary number indicates its weight, or value within
the number, just as the position of a decimal digit
determines the value of that digit. The weights in a binary
number are based on powers of two.

3/25/2023 6
As you have seen in Table, four
bits are required to count from
zero to 15. In general, with n
bits you can count up to a
number equal to 𝟐𝒏 − 𝟏.
Largest decimal number = 2𝑛 − 1
For example, with five bits (n =
5) you can count from zero to
thirty-one.
𝟐𝟓 − 𝟏= 32 - 1 = 31
With six bits (n = 6) you can
count from zero to sixty-three.
𝟐𝟔 − 𝟏= 64 - 1 = 63

3/25/2023 7
An Application
Learning to count in binary will help you to basically
understand how digital circuits can be used to count events.
Let’s take a simple example of counting tennis balls going
into a box from a conveyor belt. Assume that nine balls are to
go into each box.The counter in Figure counts the pulses
from a sensor that detects the passing of a ball and produces
a sequence of logic levels (digital waveforms) on each of its
four parallel outputs. Each set of logic levels represents a 4-
bit binary number (HIGH = 1 and LOW = 0), as indicated. As
the decoder receives these waveforms, it decodes each set
of four bits and converts it to the corresponding decimal
number in the 7-segment display.

3/25/2023 8
When the counter gets to the binary state of 1001, it has
counted nine tennis balls, the display shows decimal 9, and a
new box is moved under the conveyor belt. Then the counter
goes back to its zero state (0000), and the process starts
over. (The number 9 was used only in the interest of single-
digit simplicity.)
3/25/2023 9
The weight structure of a binary number is

where n is the number of bits from the binary point. Thus, all
the bits to the left of the binary point have weights that are
positive powers of two, as previously discussed for whole
numbers. All bits to the right of the binary point have weights
that are negative powers of two, or fractional weights. The
powers of two and their equivalent decimal weights for an 8-
bit binary whole number and a 6-bit binary fractional number
are shown

3/25/2023 10
Binary-to-Decimal Conversion
The decimal value of any binary number can be found by
adding the weights of all bits that are 1 and discarding the
weights of all bits that are 0.
Convert the binary whole number 1101101 to decimal.
Solution
Determine the weight of each bit that is a 1, and then find
the sum of the weights to get the decimal number.

3/25/2023 11
Convert the fractional binary number 0.1011
to decimal.
Solution
Determine the weight of each bit that is a 1,
and then sum the weights to get the decimal
fraction.

3/25/2023 12
Decimal to Binary Conversion
Sum-of-Weights Method
To get the binary number for a given decimal number, find the
binary weights that add up to the decimal number.
The decimal number 9, for example, can be expressed as the
sum of binary weights as follows:

Placing 1s in the appropriate weight positions, 23 and 20 ,


and 0s in the 22 and 21 positions determines the binary
number for decimal 9.

3/25/2023 13
Repeated Division-by-2 Method

A systematic method of converting whole numbers from


decimal to binary is the repeated division-by-2 process. For
example, to convert the decimal number 12 to binary, begin
by dividing 12 by 2. Then divide each resulting quotient by 2
until there is a 0 whole-number quotient. The remainders
generated by each division form the binary number. The first
remainder to be produced is the LSB (least significant bit) in
the binary number, and the last remainder to be produced is
the MSB (most significant bit). This procedure is illustrated
as follows for converting the decimal number 12 to binary.

3/25/2023 14
3/25/2023 15
3/25/2023 16
Converting Decimal Fractions to Binary

An easy way to remember fractional binary weights is that


the most significant weight is 0.5, which is 2−1 , and that by
halving any weight, you get the next lower weight; thus a list
of four fractional binary weights would be 0.5, 0.25, 0.125,
0.0625.
Sum-of-Weights
The sum-of-weights method can be applied to fractional
decimal numbers, as shown in the following example:

There is a 1 in the 𝟐−𝟏 position, a 0 in the 𝟐−𝟐 position, and a


1 in the 𝟐−𝟑 position.
3/25/2023 17
Repeated Multiplication by 2

Decimal fractions can be converted to binary by repeated


multiplication by 2. For example, to convert the decimal
fraction 0.3125 to binary, begin by multiplying 0.3125 by 2
and then multiplying each resulting fractional part of the
product by 2 until the fractional product is zero or until the
desired number of decimal places is reached. The carry
digits, or carries, generated by the multiplications produce
the binary number. The first carry produced is the MSB, and
the last carry is the LSB. This procedure is illustrated as
follows:

3/25/2023 18
3/25/2023 19
Octal Numbers

The octal number system is composed of eight digits, which


are
0, 1, 2, 3, 4, 5, 6, 7
To count above 7, begin another column and start over:
10, 11, 12, 13, 14, 15, 16, 17, 20, 21, c
Counting in octal is similar to counting in decimal, except
that the digits 8 and 9 are not used. To distinguish octal
numbers from decimal numbers or hexadecimal numbers, we
will use the subscript 8 to indicate an octal number. For
instance, 𝟏𝟓𝟖 in octal is equivalent to 𝟏𝟑𝟏𝟎 in decimal and D
in hexadecimal.

3/25/2023 20
3/25/2023 21
Octal-to-Decimal Conversion
Since the octal number system has a base of eight, each
successive digit position is an increasing power of eight,
beginning in the right-most column with 𝟖𝟎 . The evaluation of
an octal number in terms of its decimal equivalent is
accomplished by multiplying each digit by its weight and
summing the products, as illustrated here for 𝟐𝟑𝟕𝟒𝟖 .

3/25/2023 22
Decimal-to-Octal Conversion
A method of converting a decimal number to an octal number
is the repeated division by 8 method, which is similar to the
method used in the conversion of decimal numbers to
binary or to hexadecimal. To show how it works, let’s convert
the decimal number 359 to octal

3/25/2023 23
Octal-to-Binary Conversion
Because each octal digit can be represented by a 3-bit binary
number, it is very easy to convert from octal to binary. Each
octal digit is represented by three bits as shown in Table

To convert an octal number to a binary number, simply


replace each octal digit with the appropriate three bits.

3/25/2023 24
Binary-to-Octal Conversion
Conversion of a binary number to an octal number is the
reverse of the octal-to-binary conversion. The procedure is
as follows: Start with the right-most group of three bits and,
moving from right to left, convert each 3-bit group to the
equivalent octal digit. If there are not three bits available for
the left-most group, add either one or two zeros to make a
complete group. These leading zeros do not affect the value
of the binary number.

3/25/2023 25
Hexadecimal Numbers

The hexadecimal number system has a base of sixteen; that


is, it is composed of 16 numeric and alphabetic characters.
Most digital systems process binary data in groups that are
multiples of four bits, making the hexadecimal number very
convenient because each hexadecimal digit represents a 4-
bit binary number

3/25/2023 26
3/25/2023 27
Counting in Hexadecimal
How do you count in hexadecimal once you get to F? Simply
start over with another column and continue as follows:
D, E, F, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1A, 1B, 1C, 1D,
1E, 1F, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 2A, 2B, 2C, 2D,
2E, 2F, 30, 31,
With two hexadecimal digits, you can count up to 𝑭𝑭𝟏𝟔 ,
which is decimal 255. To count beyond this, three
hexadecimal digits are needed. For instance, 𝟏𝟎𝟎𝟏𝟔 is
decimal 256, 𝟏𝟎𝟏𝟏𝟔 is decimal 257, and so forth. The
maximum 3-digit hexadecimal number is 𝑭𝑭𝑭𝟏𝟔 , or decimal
4095. The maximum 4-digit hexadecimal number is 𝐹𝐹𝐹𝐹16 ,
which is decimal 65,535.

3/25/2023 28
Binary-to-Hexadecimal Conversion
Converting a binary number to hexadecimal is a
straightforward procedure. Simply break the binary number
into 4-bit groups, starting at the right-most bit and replace
each 4-bit group with the equivalent hexadecimal symbol.

3/25/2023 29
Hexadecimal-to-Binary Conversion

To convert from a hexadecimal number to a binary number,


reverse the process and replace each hexadecimal symbol
with the appropriate four bits.

3/25/2023 30
It should be clear that it is much easier to deal with a
hexadecimal number than with the equivalent binary
number. Since conversion is so easy, the hexadecimal
system is widely used for representing binary numbers in
programming, printouts, and displays.

Hexadecimal-to-Decimal Conversion

One way to find the decimal equivalent of a hexadecimal


number is to first convert the hexadecimal number to
binary and then convert from binary to decimal.

3/25/2023 31
3/25/2023 32
Another way to convert a hexadecimal
number to its decimal equivalent is to
multiply the decimal value of each
hexadecimal digit by its weight and then
take the sum of these products. The weights
of a hexadecimal number are increasing
powers of 16 (from right to left). For a 4-digit
hexadecimal number, the weights are

3/25/2023 33
Decimal-to-Hexadecimal Conversion

Repeated division of a decimal number by 16 will produce the


equivalent hexadecimal number, formed by the remainders of
the divisions. The first remainder produced is the least
significant digit (LSD). Each successive division by 16 yields
a remainder that becomes a digit in the equivalent
hexadecimal number. This procedure is similar to repeated
division by 2 for decimal-to-binary conversion. Note that
when a quotient has a fractional part, the fractional part
is multiplied by the divisor to get the remainder.

3/25/2023 34
3/25/2023 35
Octal to Hexa-Decimal Conversion:
• The simplest way is to initially convert the
given Octal numbers to Binary number and then
the binary number to Hexadecimal number.
• Eg: Convert (756.603)8 to Hexadecimal

3/25/2023 36
Hexa-Decimal to Octal Conversion:
• First convert, Hexa-decimal to Binary and then
convert to Octal.
• Eg: Convert (B9F.AE)16 to Octal

3/25/2023 37
Binary Arithmetic
Binary Addition
The four basic rules for adding binary digits (bits) are as
follows:

Notice that the first three rules result in a single bit and in
the fourth rule the addition of two 1s yields a binary two (10).
When binary numbers are added, the last condition creates a
sum of 0 in a given column and a carry of 1 over to the next
column to the left, as illustrated in the following addition of
011 + 001:
3/25/2023 38
Binary Subtraction
The four basic rules for subtracting bits are as follows:

When subtracting numbers, you sometimes have to borrow


from the next column to the left. A borrow is required in
binary only when you try to subtract a 1 from a 0. In this
case, when a 1 is borrowed from the next column to the left,
a 10 is created in the column being subtracted, and the last
of the four basic rules just listed must be applied.

3/25/2023 39
3/25/2023 40
Let’s examine exactly what was done to subtract the two
binary numbers since a borrow is required. Begin with the
right column.

3/25/2023 41
Binary Multiplication
The four basic rules for multiplying bits are as follows:

Multiplication is performed with binary numbers in the same


manner as with decimal numbers. It involves forming partial
products, shifting each successive partial product left one
place, and then adding all the partial products.

3/25/2023 42
3/25/2023 43
Computer Method of Multiplication:
• To perform multiplication, a p-bit Multiplicand
register and 2p-bit Multiplier/Result register is
required.
• The multiplier is placed in the left p-bits of the
Multiplier/ Quotient (MQ) register and the right p-
bits are set to zero.
• Multiplicand is placed in M register.
• The MQ register is then shifted one bit to the left.
• If 1 is shifted out, then add M to MQ.
• If 0 is shifted out, then add 0 to MQ.
• The entire process is repeated p-times.

3/25/2023 44
3/25/2023 45
Binary Division
Division in binary follows the same procedure as division in
decimal,

Perform the following binary divisions:


(a) 110 , 11 (b) 110 , 10

3/25/2023 46
Computer Method of Division:

3/25/2023 47
3/25/2023 48
9’s Complement and 10’s Complements of
Decimal Numbers:
• Subtraction of Decimal Numbers can be accomplished by
9’s and 10’s complement methods.
9’s Complement:
• The 9’s complement of a decimal number can be obtained
by subtracting each digit of that decimal number from 9.
• Eg: Find the 9’s complement of: (a) 3465 (b) 1264.582
Sol: (a) 9 9 9 9 (b) 9 9 9 9. 9 9 9
3465 1 2 6 4. 5 8 2
6534 8 7 3 5. 4 1 7

3/25/2023 49
10’s Complement:

The 10’s complement of a decimal number can be


obtained by adding a 1 to its 9’s complement.

Eg: Find the 10’s complement of: (a) 4069 (b) 1056.074
Sol: (a) 9 9 9 9 (b) 9 9 9 9 . 9 9 9
4069 1056.074
5930 9’s Complement 8943.925
+1 + 1
5931 10’s Complement 8943.926

3/25/2023 50
9’s Complement Method of Subtraction:

• To perform Decimal subtraction using 9’s Complement


method, obtain the 9’s complement of the subtrahend
and add it to the minuend. This is the Intermediate
result.
• If there is a carry, it indicates the answer is positive.
Add the carry to the LSD of this result to get the
answer. This is called END ARROUND CARRY.
• If there is no carry, it indicates that the answer is
negative and the intermediate result is its 9’s
complement.
• Take the 9’s complement of this result and place a
negative sign in front to get the answer.
3/25/2023 51
Eg: Subtract the following numbers using 9’s
complement method of subtraction

3/25/2023 52
10’s Complement Method of Subtraction:
• To perform Decimal subtraction using 10’s Complement
method, obtain the 10’s complement of the subtrahend
and add it to the minuend.
• If there is a carry, ignore it. The presence of the carry
indicates, the answer is positive, and the result obtain
is itself the answer.
• If there is no carry, it indicates that the answer is
negative and the result obtained is its 10’s
complement.
• Obtain the 10’s complement of this result and place a
negative sign in front to get the answer.

3/25/2023 53
Eg: Subtract the following numbers using 10’s
complement method of subtraction.

3/25/2023 54
Complements of Binary Numbers
Finding the 1’s Complement
The 1’s complement of a binary number is found by changing
all 1s to 0s and all 0s to 1s,
as illustrated below:

The simplest way to obtain the 1’s complement of a binary


number with a digital circuit is to use parallel inverters (NOT
circuits),

3/25/2023 55
Finding the 2’s Complement
The 2’s complement of a binary number is found by adding 1
to the LSB of the 1’s complement. 2’s complement = (1’s
complement) + 1

3/25/2023 56
An alternative method of finding the 2’s complement of a
binary number is as follows:
1. Start at the right with the LSB and write the bits as they
are up to and including the first 1.
2. Take the 1’s complements of the remaining bits.

3/25/2023 57
The 2’s complement of a negative binary number can be
realized using inverters and an adder, as indicated in Figure.
This illustrates how an 8-bit number can be converted to its
2’s complement by first inverting each bit (taking the 1’s
complement) and then adding 1 to the 1’s complement with
an adder circuit.

3/25/2023 58
To convert from a 1’s or 2’s complement back to the true
(uncomplemented) binary form, use the same two procedures
described previously. To go from the 1’s complement back to
true binary, reverse all the bits. To go from the 2’s
complement form back to true binary, take the 1’s
complement of the 2’s complement number and add 1 to the
least significant bit.

Signed Binary Numbers


The Sign Bit:
The left-most bit in a signed binary number is the sign bit,
which tells you whether the number is positive or negative.
A 0 sign bit indicates a positive number, and a 1 sign bit
indicates a negative number.
3/25/2023 59
Sign-Magnitude Form
When a signed binary number is represented in sign-
magnitude, the left-most bit is the sign bit and the remaining
bits are the magnitude bits. The magnitude bits are in true
(uncomplemented) binary for both positive and negative
numbers. For example, the decimal number +25 is expressed
as an 8-bit signed binary number using the sign-magnitude
form as

3/25/2023 60
The decimal number -25 is expressed as
10011001
Notice that the only difference between +25 and -25 is the
sign bit because the magnitude bits are in true binary for
both positive and negative numbers.
In the sign-magnitude form, a negative number has the same
magnitude bits as the corresponding positive number but the
sign bit is a 1 rather than a zero.

1’s Complement Form


Positive numbers in 1’s complement form are represented the
same way as the positive sign-magnitude numbers. Negative
numbers, however, are the 1’s complements of the
corresponding positive numbers.
3/25/2023 61
For example, using eight bits, the decimal number -25 is
expressed as the 1’s complement of +25 (00011001) as
11100110
In the 1’s complement form, a negative number is the 1’s
complement of the corresponding positive number.

2’s Complement Form


Positive numbers in 2’s complement form are represented the
same way as in the sign magnitude and 1’s complement
forms. Negative numbers are the 2’s complements of the
corresponding positive numbers

3/25/2023 62
Again, using eight bits, let’s take decimal number -25 and
express it as the 2’s complement of +25 (00011001).
Inverting each bit and adding 1, you get -25 = 11100111
In the 2’s complement form, a negative number is the 2’s
complement of the corresponding positive number.

3/25/2023 63
The Decimal Value of Signed Numbers
Sign-Magnitude
Decimal values of positive and negative numbers in the sign-
magnitude form are determined by summing the weights in
all the magnitude bit positions where there are 1s and
ignoring those positions where there are zeros. The sign is
determined by examination of the sign bit.

3/25/2023 64
1’s Complement
Decimal values of positive numbers in the 1’s complement
form are determined by summing the weights in all bit
positions where there are 1s and ignoring those positions
where there are zeros. Decimal values of negative numbers
are determined by assigning a negative value to the weight
of the sign bit, summing all the weights where there are 1s,
and adding 1 to the result.

3/25/2023 65
3/25/2023 66
2’s Complement
• Decimal values of positive and negative numbers in
the 2’s complement form are determined by
summing the weights in all bit positions where
there are 1s and ignoring those positions where
there are zeros. The weight of the sign bit in a
negative number is given a negative value.
Special case in 2’s complement representation:
• Whenever a signed number has a 1 in the sign bit
and all 0s for the magnitude bits, the decimal
equivalent is - 𝟐𝒏 , where n is the number of bits in
the magnitude.
• Eg: 1000=-8 and 10000=-16

3/25/2023 67
3/25/2023 68
From these examples, you can see why the 2’s complement
form is preferred for representing signed integer numbers: To
convert to decimal, it simply requires a summation of
weights regardless of whether the number is positive or
negative. The 1’s complement system requires adding 1 to
the summation of weights for negative numbers but not for
positive numbers. Also, the 1’s complement form is generally
not used because two representations of zero (00000000 or
11111111) are possible.

3/25/2023 69
Range of Signed Integer Numbers

We have used 8-bit numbers for illustration because the


8-bit grouping is common in most computers and has
been given the special name byte. With one byte or eight
bits, you can represent 256 different numbers. With two
bytes or sixteen bits, you can represent 65,536 different
numbers. With four bytes or 32 bits, you can represent
4.295 *𝟏𝟎𝟗 different numbers. The formula for finding the
number of different combinations of n bits is
Total combinations = 𝟐𝒏

3/25/2023 70
For 2’s complement signed numbers, the range of
values for n -bit numbers is
Range = -( 𝟐𝒏−𝟏 ) to +( 𝟐𝒏−𝟏 - 1)
where in each case there is one sign bit and n -1
magnitude bits. For example, with four bits you can
represent numbers in 2’s complement ranging from
-𝟐𝟑 = -8 to 𝟐𝟑 -1 = +7.
Similarly, with eight bits you can go from -128 to
+127, with sixteen bits you can go from -32,768 to
+32,767, and so on. There is one less positive
number than there are negative numbers because
zero is represented as a positive number (all zeros).

3/25/2023 71
Example For n=4 Example:
Decimal 2’s Decimal 2’s Representation of -4 in
Complement Complement 2’s complement form
+4=0100
+0 0000 -8 1000 -4=2’s complement of
0100=1011+1
+1 0001 -7 1001 =1100
+2 0010 -6 1010
+3 0011 -5 1011
+4 0100 -4 1100
+5 0101 -3 1101
+6 0110 -2 1110
+7 0111 -1 1111
3/25/2023 72
3/25/2023 73
3/25/2023 74
Eg: Convert the given signed binary number to decimal
equivalent using Sign-magnitude form, 1’s complement form
and 2’s complement form.

BINARY SIGN-MAGNITUDE 1’s COMPLEMENT FORM 2’s COMPLEMENT FORM


FORM
01101 + 13 + 13 + 13

010111 + 23 + 23 + 23

10111 -7 -8 -9

1101010 - 42 - 21 - 22

3/25/2023 75
Arithmetic Operations With Signed Numbers
Addition
The two numbers in an addition are the addend and the
augend. The result is the sum. There are four cases that
can occur when two signed binary numbers are added.
1. Both numbers positive
2. Positive number with magnitude larger than negative
number
3. Negative number with magnitude larger than positive
number
4. Both numbers negative
Take one case at a time using 8-bit signed numbers as
examples. The equivalent decimal numbers are shown
for reference.
3/25/2023 76
3/25/2023 77
In a computer, the negative numbers are stored in 2’s
complement form so, as you can see, the addition process is
very simple: Add the two numbers and discard any final carry
bit.
Overflow Condition
When two numbers are added and the number of bits
required to represent the sum exceeds the number of bits in
the two numbers, an overflow results as indicated by an
incorrect sign bit. An overflow can occur only when both
numbers are positive or both numbers are negative. If the
sign bit of the result is different than the sign bit of the
numbers that are added, overflow is indicated.

3/25/2023 78
In this example the sum of 183 requires eight magnitude bits.
Since there are seven magnitude bits in the numbers (one bit
is the sign), there is a carry into the sign bit which produces
the overflow indication.

3/25/2023 79
Subtraction
Subtraction is a special case of addition. For example,
subtracting +6 (the subtrahend) from +9 (the minuend)
is equivalent to adding -6 to +9. Basically, the
subtraction operation changes the sign of the
subtrahend and adds it to the minuend. The result of a
subtraction is called the difference. The sign of a
positive or negative binary number is changed by taking
its 2’s complement.
For example, when you take the 2’s complement of the
positive number 00000100 (+4), you get 11111100,
which is -4 as the following sum-of-weights evaluation
shows:
-128 + 64 + 32 + 16 + 8 + 4 = -4
3/25/2023 80
As another example, when you take the 2’s complement of
the negative number 11101101 (-19), you get 00010011,
which is +19 as the following sum-of-weights evaluation
shows:
16 + 2 + 1 = 19

Since subtraction is simply an addition with the sign of the


subtrahend changed, the process is stated as follows:
To subtract two signed numbers, take the 2’s complement of
the subtrahend and add. Discard any final carry bit.

3/25/2023 81
3/25/2023 82
P) Perform the subtraction with the following Unsigned binary
numbers using 1’s and 2’s complement of the subtrahend.
a) 11010-10000 b) 11010-1101 c) 1010100-1010100

3/25/2023 83
P) The binary numbers listed have a sign bit in the left most
position and if negative, numbers are in 2’s complement
form. Perform the arithmetic operations and verify the
answers.
a) 101011 + 111000 b) 001110 + 110010
Sol:

3/25/2023 84
c) 111001 - 001010 d) 101011 - 100110

3/25/2023 85
Multiplication

Direct addition and Partial products are two basic methods


for performing multiplication using addition.
In the direct addition method, you add the multiplicand a
number of times equal to the multiplier. In the previous
decimal example (8 * 3), three multiplicands are added: 8 + 8
+ 8 = 24. The disadvantage of this approach is that it becomes
very lengthy if the multiplier is a large number. For example,
to multiply 350 * 75, you must add 350 to itself 75 times.
Incidentally, this is why the term times is used to mean
multiply. When two binary numbers are multiplied, both
numbers must be in true (uncomplemented) form.

3/25/2023 86
3/25/2023 87
The partial products method is perhaps the more common one
because it reflects the way you multiply longhand. The
multiplicand is multiplied by each multiplier digit beginning
with the least significant digit. The result of the multiplication
of the multiplicand by a multiplier digit is called a partial
product. Each successive partial product is moved (shifted) one
place to the left and when all the partial products have been
produced, they are added to get the final product.
The sign of the product of a multiplication depends on the
signs of the multiplicand and the multiplier according to the
following two rules:
▪ If the signs are the same, the product is positive.
▪ If the signs are different, the product is negative.

3/25/2023 88
3/25/2023 89
3/25/2023 90
Division
The numbers in a division are the dividend, the divisor, and
the quotient. These are illustrated in the following standard
division format.
𝑫𝒊𝒗𝒊𝒅𝒆𝒏𝒅
= 𝑸𝒖𝒐𝒕𝒊𝒆𝒏𝒕
𝑫𝒊𝒗𝒊𝒔𝒐𝒓
The division operation in computers is accomplished using
subtraction. Since subtraction is done with an adder, division
can also be accomplished with an adder.
The result of a division is called the quotient; the quotient is
the number of times that the divisor will go into the dividend.
The sign of the quotient depends on the signs of the dividend
and the divisor according to the following two rules:
▪ If the signs are the same, the quotient is positive.
▪ If the signs are different, the quotient is negative.

3/25/2023 91
When two binary numbers are divided, both numbers must be
in true (uncomplemented) form. The basic steps in a division
process are as follows:
Step 1: Determine if the signs of the dividend and divisor are
the same or different. This determines what the sign of the
quotient will be. Initialize the quotient to zero.
Step 2: Subtract the divisor from the dividend using 2’s
complement addition to get the first partial remainder and add
1 to the quotient. If this partial remainder is positive, go to
step 3. If the partial remainder is zero or negative, the division
is complete.
Step 3: Subtract the divisor from the partial remainder and add
1 to the quotient. If the result is positive, repeat for the next
partial remainder. If the result is zero or negative, the division
is complete.
3/25/2023 92
Continue to subtract the divisor from the dividend and the
partial remainders until there is a zero or a negative result.
Count the number of times that the divisor is subtracted and
you have the quotient.

3/25/2023 93
3/25/2023 94
Hexadecimal Addition

Addition can be done directly with hexadecimal numbers


by remembering that the hexadecimal digits 0 through 9
are equivalent to decimal digits 0 through 9 and that
hexadecimal digits A through F are equivalent to decimal
numbers 10 through 15. When adding two hexadecimal
numbers, use the following rules. (Decimal numbers are
indicated by a subscript 10.)
1. In any given column of an addition problem, think of
the two hexadecimal digits in terms of their decimal
values. For instance, 𝟓𝟏𝟎 = 𝟓𝟏𝟔 and 𝑪𝟏𝟔 = 𝟏𝟐𝟏𝟎 .

3/25/2023 95
2. If the sum of these two digits is 𝟏𝟓𝟏𝟎 or less, bring
down the corresponding hexadecimal digit.
3. If the sum of these two digits is greater than 𝟏𝟓𝟏𝟎 ,
bring down the amount of the sum that exceeds 𝟏𝟔𝟏𝟎 and
carry a 1 to the next column.

3/25/2023 96
3/25/2023 97
Hexadecimal Subtraction

As you have learned, the 2’s complement allows you to


subtract by adding binary numbers. Since a hexadecimal
number can be used to represent a binary number, it can
also be used to represent the 2’s complement of a binary
number. There are three ways to get the 2’s complement
of a hexadecimal number. Method 1 is the most common
and easiest to use. Methods 2 and 3 are alternate
methods.
Method 1: Convert the hexadecimal number to binary.
Take the 2’s complement of the binary number. Convert
the result to hexadecimal.

3/25/2023 98
Method 2: Subtract the hexadecimal number from the
maximum hexadecimal number and add 1.

3/25/2023 99
Method 3: Write the sequence of single hexadecimal
digits. Write the sequence in reverse below the forward
sequence. The 1’s complement of each hex digit is the
digit directly below it and add 1.

3/25/2023 100
3/25/2023 101
7’s Complement and 8’s Complements of Octal
Numbers:
Eg: Express 326 in 7’s and 8’s complement form.
Sol:
7’s Complement: 777
326
451

8’s Complement: (7’s Complement+1)


451
+1
452

3/25/2023 102
15’s Complement and 16’s Complements of Hexa-
Decimal Numbers:
Eg: Express E8A, 1B06 in 15’s and 16’s complement form.
Sol:
15’s Complement: F F F FFFF
E8A 1B06
175 E4F9
16’s Complement: +1 +1
176 E4FA

3/25/2023 103

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy