0% found this document useful (0 votes)
25 views25 pages

ARITHMETIC CIRCUIT EEng

The document discusses different methods for representing signed binary numbers, including sign-magnitude, 1's complement, and 2's complement representations. It explains how negative numbers are represented and arithmetic is performed using the 1's complement and 2's complement methods, which are important because they allow computers to perform subtraction by adding the complement of a number.

Uploaded by

Nina Tina
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)
25 views25 pages

ARITHMETIC CIRCUIT EEng

The document discusses different methods for representing signed binary numbers, including sign-magnitude, 1's complement, and 2's complement representations. It explains how negative numbers are represented and arithmetic is performed using the 1's complement and 2's complement methods, which are important because they allow computers to perform subtraction by adding the complement of a number.

Uploaded by

Nina Tina
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/ 25

ARITHMETIC CIRCUIT

SIGNED NUMBERS
‰ Digital systems, such as the computer, must be able to
handle both positive and negative numbers.
‰ A signed binary number consists of both sign and
magnitude information.
‰ The sign indicates whether a number is positive or
negative and
‰ the magnitude is the value of the number.
‰ There are three forms in which signed integer (whole)
numbers can be represented in binary:
‰ Sign-magnitude,
‰ 1's complement, and
‰ 2's complement.
™ Of these, the 2's complement is the most important and
the sign-magnitude is rarely used.
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 is for positive, and
‰ a 1 is for negative
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
00011001
Sign bit Magnitude bits
‰ The decimal number −25 is expressed as 10011001
‰ Notice that the only difference between +25 and -25 is the sign bit because the magni­tude 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 and 2’s Complements of Binary Numbers

‰The 1's complement and the 2's complement of a


binary number are important because they permit
the representation of negative numbers.
‰The method of 2's complement , arithmetic is
commonly used in computers to handle negative
numbers.
Finding the 1's Complement of a Binary Number
‰The 1's complement of a binary number is found
by changing all 1s to 0s and all 0s to 1s, illustrated
below:
10110010 Binary number
↓ ↓ ↓ ↓ ↓ ↓ ↓↓
01001101 1’s complement
Finding the 2's Complement of a Binary Number
‰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
Example
Find the 2's complement of 10110010.
Solution
10110010 Binary number
01001101 1's complement
+ 1 Add 1
01001110 2's complement
REPRESENTATION OF SIGNED NUMBERS AND
BINARY ARITHMETIC IN COMPUTERS
‰ So far, we have considered only positive numbers. The representation
of negative is also equally important. There are two ways of
representing signed numbers:
‰ sign- magnitude form and
‰ complement form.
‰ There are two complement forms:
‰ 1's complement form and
‰ 2's complement form.
‰ Most digital computers do subtraction by the 2's complement method,
but some do it by the 1's complement method.
‰ The advantage of performing subtraction by the complement
method is reduction in the hardware.
‰ Instead of having separate digital circuits for addition and subtraction,
only adding circuits are needed.
‰ That is, subtraction is also performed by adders only. Instead of
subtracting one number from the other, the complement of the
subtrahend is added to the minuend.
‰ In sign-magnitude form, an additional bit called the sign bit is placed in
front of the number.
‰ If the sign bit is a 0, the number is positive. If it is a 1, the number is
negative.
• Example of Signed-magnitude form

0 1 0 1 0 0 1 +41
Sign bit Magnitude bit

1 1 0 1 0 0 1 -41
Sign bit Magnitude bit

‰Under the signed-magnitude system, a great


deal of manipulation is necessary to add a
positive number to a negative number.
‰Thus, though the signed-magnitude number
system is possible, it is impractical.
Representation of Signed Numbers Using the
2's (or 1's) Complement Method
The 2's (or 1's) complement system for
representing signed numbers works like this:
1. If the number is positive, the magnitude is
represented in its true binary form and a sign bit 0
is placed in front of the MSB.
2. If the number is negative, the magnitude is
represented in its complement form and a sign bit
1 is placed in front of the MSB.
‰ That is, to represent the numbers in sign 2's (or
1's) complement form, determine the 2's (or 1's)
complement of the magnitude of the number and
then attach the sign bit.
‰ The conversion of complement to true binary is
the same as the process used to convert true
binary to complement.
™ Example on representation of + 51 and - 51 in both 2's and 1's
complement forms is shown below:

0 1 1 0 0 1 1 +51 ( in signed magnitude form)


( in 2’s complement form)
Sign bit Magnitude
( In 1’s complement form)

1 1 1 0 0 1 1 -51 ( in signed magnitude form)


Sign bit Magnitude

1 0 0 1 1 0 0 -51 (In 1’s complement form)

Sign bit Magnitude

1 0 0 1 1 0 1 -51 (in 2’s complement form)

Sign bit Magnitude


™ To subtract using the 2's (or 1's) complement method; represent
both the subtrahend and the minuend by the same number of
bits.
™ Take the 2's (or 1's) complement of the subtrahend including the
sign bit.
™ Keep the minuend in its original form and add the 2's (or 1's)
complement of the subtrahend to it.
™ The choice of 0 for positive sign and 1 for negative sign is not
arbitrary.
™ In fact, this choice makes it possible to add the sign bits in binary
addition just as other bits are added.
™ When the sign bit is a 0, the remaining bits represent magnitude,
and
™ when the sign bit is a 1, the remaining bits represent 2's or 1's
complement of the number.
™ The polarity of the signed number can be changed simply by
performing the complement on the complete number.
Special case in 2's complement representation:
* Whenever a signed number has a 1 in sign bit and all 0s for the
magnitude bits, the decimal equivalent is -2n, where n number of
bits in the magnitude. For example, 1000 = - 8 and 10000 = - 16.
‰ Characteristics of the 2's complement numbers.

‰ The 2's complement numbers have the following properties:


‰ There is one unique zero.
‰ The 2's complement of 0 is 0.
‰ The left most bit cannot be used to express a quantity. It is a
sign bit. If it is a 1, the number is negative and if it is a 0, the
number is positive.
‰ For an n-bit word which includes the sign bit, there are 2n-1 - 1
positive integers, 2n-1 negative integers and one 0, for a total
of 2n unique states.
‰ Significant information is contained in the 1s of the positive
numbers and 0s of the negative numbers.
‰ A negative number may be converted into a positive number
by finding its 2's complement.
Methods of obtaining the 2's complement of a
number:
‰The 2's complement of a number can be
obtained in three ways as given below.
‰By obtaining the 1's complement of the
given number (by changing all 0s to 1s and
1s to 0s) and then adding 1.
‰By subtracting the given n-bit number N
from 2n.
‰Starting at the LSB, copying down each bit
up to and including the first 1 bit
encountered, and complementing the
remaining bits.
Example: Express -45 in 8-bit 2’s complement form.
Solution
+45 in 8-bit form is 00101101.
First method
Obtain the 1’s complement of 00101101 and then add 1.
Positive expression of the given number 00101101
1’s complement of it 11010010
Add 1 +1
Thus, the 2’s complement form of -45 is 11010011
Second method
Subtract the given number N from 2n
2n = 100000000
Subtract 45 = − 00101101
Thus, the 2’s complement form of -45 is 11010011
Third method
Copy down the bits starting from LSB up to and including the first 1, and
then complement the remaining bits.
Original number 00101101
Copy up to first 1 bit 1
Complement the remaining bits 1010011
Thus, the 2’s complement form of -45 is 11010011
Two's Complement Arithmetic
‰ The 2's complement system is used to represent negative
numbers using modulus arithmetic.
‰ The word length of a computer is fixed.
‰ That means if a 4-bit number is added to another 4-bit
number, the result will be only of 4 bits. Carry, if any, from
the fourth bit will overflow.
‰ This is called the modulus arithmetic.
For example: 1100 + 1111 = 1011.
‰ In the 2's complement subtraction, add the 2's complement
of the subtrahend to the minuend.
‰ If there is a carry out, ignore it. Look at the sign bit, i.e. MSB
of the sum term.
‰ If the MSB is a 0, the result is positive and is in true binary
form.
‰ If the MSB is a 1 (whether there is a carry or no carry at all)
the result is negative and is in its 2's complement form.
‰ Take its 2's complement to find its magnitude in binary.
Example: subtract 14 from 46 using the 8-bit 2’s
complement arithmetic.
Solution
+14 = 00001110
−14 = 11110010 (in 2’s complement form)

+46 00101110
−14 ⇒ +11110010 (2’s complement form of−14)
+32 100100000 (Ignore the carry)
‰There is a carry, ignore it.
‰The MSB is 0; so, the result is positive and is in
normal binary form.
‰Therefore, the result is +00100000=+32
Example: add −75 to +26 using the 8-bit 2’s
complement arithmetic
Solution
+75 = 01001011
−75 = 10110101 (in 2’s complement form)

+26 00011010
−75 ⇒ +10110101 (2’s complement form of -75)
−49 11001111 (No carry)
‰There is no carry, the MSB is a 1.
‰So, the result is negative and is in 2’s complement
form.
‰The magnitude is 2’s complement of 11001111,
that is, 00110001=49.
‰Therefore, the result is −49.
One's Complement Arithmetic
‰ The 1's complement of a number is obtained by simply complementing each bit of
the number, that is, by changing all the 0s to 1 s and all the 1 s to 0s.
‰ We can also say that the 1's complement of a number is obtained by subtracting
each bit of the number from l.
‰ This complemented value represents the negative of the original number.
‰ This system is very easy to implement in hardware by simply feeding all bits
through inverters.
‰ One of the difficulties of using 1's complement is its representation of zero.
‰ Both 00000000 and its 1's complement 11111111 represent zero.
‰ The 00000000 is called positive zero and the 11111111 is called negative zero.
‰ In 1's complement subtraction, add the 1's complement of the subtrahend to the
minuend.
‰ If there is a carry out, bring the carry around and add it to the LSB. This is called
the end around carry.
‰ Look at the sign bit (MSB); if this is a 0, the result is positive and is in true binary.
‰ If the MSB is a 1 (whether there is a carry or no carry at all), the result is negative
and is in its 1's complement form. Take its 1's complement to get the magnitude in
binary.
Example: subtract 14 from 25 using the 8-bit 1’s
complement arithmetic
Solution
+25 00011001
−14 ⇒ +11110001 (1’s complement form of −14)
+11 100001010
+1 (Add the end around carry)
00001011 =+ 1110
Example: Add −25 to 14 using the 8-bit 1’s
complement method.
Solution
+14 00001110
−25 ⇒ +11100110 (1’s complement form of −25)
−11 11110100 (No carry)
‰There is no carry, the MSB is a 1.
‰So, the result is negative and is in its 1’s
complement form.
‰The 1’s complement of 11110100 is
00001011.
‰The result is, therefore, −1110.
‰ The two numbers in addition are the addend
and the augend. The result is the sum. The 2’s
compliment will be used to represent negative
numbers.
‰ There are four cases that must be considered
when adding two numbers:
1. Both numbers positive
2. Positive number and smaller negative number
3. Positive number and larger negative number
4. Both numbers negative
We will take one case at a time. Eight bits are
used to represent each number
1. Both numbers positive:
™ In this case, both sign bits are zero and a 2's compliment
is not required. To illustrate, we will add +7 and +4:
7 00000111
+4 00000100
11 00001011
2. Positive number and smaller negative number:
™ In this case, the true binary form of the positive number is
added to the 2's complement of the negative number.
™ The sign bits are included in the addition, and the result
will be positive. To illustrate we will add + 15 and -6:
15 00001111
+ -6 11111010
9 100001001
Discard carry
Notice that the sign of the sum is positive (0) as it should be.
3. Positive number and larger negative number:
™ Again, the true binary form of positive number is added
to the 2's complement of the negative number.
™ The sign bits are included in the addition, and the result
will be negative. To illustrate will add + 16 and - 24:
16 00010000
+ -24 11101000 (2’s complement of -24)
-8 11111000 (2’s complement of -8)
™ Notice that the result automatically comes out in 2's
complement because it is a negative number.
4. Both numbers negative:
™ In this case, the 2's complements of both numbers added
and, of course, the sum is a negative number in 2's
complement form illustrate, we will add - 5 and -9:
-5 11111011 (2’s complement of -5)
+ -9 11110111 (2’s complement of -9)
-14 111110010 (2’s complement of -14)
Discard carry
Overflow
™ When the number of bits in the sum exceeds the number
of bits in each of numbers added, overflow results, as
illustrated by the following example.

™ The overflow condition can occur only when both


numbers are positive or both numbers are negative. An
overflow result is indicated by an incorrect sign bit.
Binary Subtraction
™Subtraction is a special case of addition.
™For example, subtracting +6 (subtrahend) from
+9 (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 2's complement method can be used in
subtraction that all operations require only
addition.
™The four cases that were discussed relation to
the addition of signed numbers apply to the
subtraction process because subtraction can be
essentially reduced to an addition process.
Parallel adder/Subtractor using 2’s Complement system

B3 B3 B2 B 2 B1 B1 B0 B0
ADD / SUB

You might also like