CO Notes (Arithematic Operations)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Binary Addition and Subtraction

with Examples
The binary addition & subtraction is similar to the decimal number system. But the main
difference between these two is, binary number system uses two digits like 0 & 1 whereas the
decimal number system uses digits from 0 to 9 and the base of this is 10. There are some specific
rules for the binary system. Like when we add & subtract binary numbers then we must be very
careful while carrying otherwise borrowing digits because these will occur more frequently. This
article discusses an overview of the addition & subtraction of binary numbers in detail below.
What is Binary Addition & Subtraction?
If a computer is accomplished in handling 5-bit numbers like -1101 where the minus is a sign bit
and remaining digits are magnitude bits then this 5-bit number can be represented like 11101.
Here in this digit, the first digit ‘1’ specifies the negative sign as well as remaining 4 digits are
the magnitude of the numbers.

Binary Addition
Binary addition technique is similar to the normal addition of decimal numbers excluding that as
an alternative value of 10 digits, it carries on a 2 value.

For example, as we compute 7+9 manually, then the answer is 16. So we know that the result has
to write like two digits 1 and 6. The main reason to write down the result like 1 6 is, the addition
of 7 + 9 is greater than the single digit. So the result cannot be denoted through a single digit
because the largest single digit is ‘9’.

Similarly, whenever we would like to sum two binary numbers, only we will have a carry if the
product is bigger than 1 because, in binary numbers, 1 is the highest number. The binary addition
rules are given in the following truth table of subtraction.

A B A+B Carry

0 0 0 0

0 1 1 0

1 0 1 0

1 1 0 1
In the above tabular form, the initial three equations are the same for the binary digit number.
The addition of binary numbers step by step is explained in detail. For binary addition take an
example of 11011 & 10101.

1 1 1 1 (Carry)
1 1 0 1 1 (27)

(+) 1 0 1 0 1 (21)

____________

1 1 0 0 0 0 (48)

Here the step by step binary addition rules is explained below

1 + 1 => 1 0, so 0 with a carry 1


1 + 1 + 0 => 1 0. So 0 with carry 1
1+0+1 => 10 => 0. So 0 with carry 1
1+1+0 => 10 => 10 = 0 with carry 1
1+1+1=> 10+1 => 11= 1 with carry 1
1 +1 +1 = 11

Binary Subtraction: First Method


In subtraction, this is the primary technique. In this method, ensure that the subtracting number
must be from a larger number to smaller, or else this technique won’t work appropriately.

If the minuend is smaller than the subtrahend, then this method is used by just switch their
positions and memorize that the effect will be a -ve number. The binary subtraction rules are
given in the following truth table of subtraction.
A B A-B Borrow

0 0 0 0

0 1 1 1

1 0 1 0

1 1 0 0

For example, in the binary subtraction, subtract the subtrahend from minuend. Take an example
of subtrahend (11011)2 and minuend (1101101)2. For subtraction, arrange these two like the
subtrahend should be below the minuend. The example of this is given below.

1101101
– 11011
To get the same number of digits in subtrahend, add zeros where it requires.

1101101
– 0011011
________
1010010
In the above binary subtraction example, the subtraction was achieved from the right side to the
left side with the help of tabular form which is shown in the above. Here the step by step binary
subtraction rules is explained below.

If the input 1 1 = 0, then borrow to the next step is 0.

If the input 0 1 = 1 & borrow is 0. So 1 0 = 1 then borrow to the next step is 1.

If the input 1 0 = 0 & borrow is. So 1 1 = 0 then borrow to the next step is 0.
If the input 1 1 = 0 & borrow is 0. So 0 0 = 0 then borrow to the next step is 0.

If the input 0 1 = 1 & borrow is 0. So 1 0 = 1 then borrow to the next step is 1.

If the input 1 0 =1 & borrow is 1. So 1 1 = 0, then borrow to the next step is 0.

Final step, If the input 1 0 = 0 & borrow is 0. So 10 = 1, then borrow to the next step is 0.

So the final result will be 1010010

Second Method: Two’s Complement


First, confirm that the digits in the subtrahend and minuends should be equal. In the above
example, the digits in the minuends have 7 whereas in subtrahend the digits are 5. So we need to
extend the digits in subtrahend by adding zeros. A 2’s complement of a number can be achieved
by complementing each digit of the number like zero’s to ones and ones to zeros. Finally, add
one to one’s complement. An example of this two’s complement is shown below.

0011011
1’s complement can be achieved by converting 0’s to 1’s and 1’s to 0’s. So the result will be like
the following.

0011011 – – – -> 1100100 (1’s complement)


2’s complement can be achieved by adding 1 to 1’s complement. So the result will be like the
following.

1100100
+ 0000001
_________
= 1100101
Now add the subtrahend‘s 2’s complement & minuend.

1101101 (subtrahend)
+ 1100101 (2’s complement)

________

(MSB) (1)1010010
In the above result, ignore the MSB (most significant bit) of the outcome. If there is no
additional bit, you did a mistake while adding the digits.
Overflow
Overflow Rule for addition
If 2 Two's Complement numbers are added, and they both have the same sign (both positive or
both negative), then overflow occurs if and only if the result has the opposite sign. Overflow
never occurs when adding operands with different signs.
i.e. Adding two positive numbers must give a positive result
Adding two negative numbers must give a negative result
Overflow occurs if
 (+A) + (+B) = −C
 (−A) + (−B) = +C
(−7) 1001
+(−6) 1010
------------
(−13) 1 0011 = 3 : Overflow (largest −ve number is −8)

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.
Overflow occurs if
 (+A) − (−B) = −C
 (−A) − (+B) = +C
Subtract −6 from +7
(+7) 0111 0111
−(−6) 1010 -> Negate -> +0110
---------- -----
13 1101 = −8 + 5 = −3 : Overflow

Another Rule to detect an overflow

If the carry into the sign bit position differs from the carry out from the sign bit position then an
overflow has occurred.

Then the operation to add (+70) to (+80) is:

Carries 0 1 overflow

+70 0 100 0110


+80 0 101 0000

+150 1 001 0110

Also look at the addition of -70 and -80

Carries 1 0 overflow

-70 1 011 1010

-80 1 011 0000

-150 0 110 1010

The circuit:

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