You are on page 1of 18

Signed Binary Arithmetic

ARITHMETIC IN 2’S COMPLEMENT METHOD


ADDITION IN THE 2’S-COMPLEMENT SYSTEM

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

It may also be mentioned here that, in general, 2’s complement notation can be
used to perform addition when the expected result of addition lies in the range
from
METHODOLOGY FOR 2’S-COMPLEMENT ADDITION

1. Represent numbers with required number of bits


2. Represent the two numbers two be added in 2’s complement
form.(augend and addend)
3. Do the binary addition using binary arithmetic. (augend +
addend=sum)
4. Ignore the carry, if it is generated.
5. If the MSB is 0, then the answer is positive i.e., it is in true
form. If MSB of the result is 1, then the answer is negative i.e.,
it is in 2’s complement form. So, we have to obtain 2’s
complement of this result to get final answer.
CASE I: TWO POSITIVE NUMBERS
CASE II:
POSITIVE NUMBER AND SMALLER NEGATIVE NUMBER
CASE III:
POSITIVE NUMBER AND LARGER NEGATIVE NUMBER
CASE IV: TWO NEGATIVE NUMBERS
ARITHMETIC OVERFLOW
a. If the magnitude of the number after addition operation exceeds the
allotted number of bits, an overflow occurs.
b. 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.
c. Overflow can occur only when adding two numbers that have the same
sign.
d. Overflow can be detected by checking to see that the sign bit of the result
is the same as the sign bits of the numbers being added.
e. Overflow detection is easily implemented in electronic circuit and it is a
standard feature in digital adder circuits.
OVERFLOW RULE FOR ADDITION

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.
SUBTRACTION IN THE 2’S-COMPLEMENT SYSTEM
The general format for subtraction is

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. Subtraction is a special case of addition.
The subtraction operation using the 2’s-complement system involves the
operation of addition.
The subtraction of a binary number B from another binary number A is
equivalent to the addition of the 2’s complement of B with A, i.e. (A-B)= A
+ 2’s complement of B.
METHODOLOGY FOR 2’S-COMPLEMENT SUBTRACTION

1. Represent numbers with required number of bits

2. Represent the minuend and subtrahend in 2’s complement form.

3. Add the 2’s complement of subtrahend to the minuend.

4. Ignore the carry, if it is generated.

5. If the MSB is 0, then the answer is positive i.e., it is in true form. If MSB
of the result is 1, then the answer is negative i.e., it is in 2’s complement
form. So, we have to obtain 2’s complement of this result to get final
answer.
CASE 1
BOTH MINUEND AND SUBTRAHEND ARE POSITIVE (THE
SUBTRAHEND IS THE SMALLER OF THE TWO)
CASE 2
BOTH MINUEND AND SUBTRAHEND ARE POSITIVE
(THE SUBTRAHEND IS THE SMALLER OF THE TWO)
CASE 3
THE MINUEND IS POSITIVE
(THE SUBTRAHEND IS NEGATIVE AND SMALLER IN MAGNITUDE)
CASE 4
THE MINUEND IS POSITIVE
(THE SUBTRAHEND IS NEGATIVE AND GREATER IN MAGNITUDE)
CASE 5
BOTH MINUEND AND SUBTRAHEND ARE NEGATIVE (THE
MINUEND IS THE SMALLER OF THE TWO)
CASE 6
BOTH MINUEND AND SUBTRAHEND ARE NEGATIVE (THE
MINUEND IS THE LARGER OF THE TWO)
OVERFLOW RULE FOR SUBTRACTION

If 2 Two's Complement numbers are subtracted, and their signs are


different, then overflow occurs if and only if the result has the same sign as
the subtrahend.

You might also like