0% found this document useful (0 votes)
8 views21 pages

Binary Arithmetic 1s and 2s complement

The document explains binary arithmetic, focusing on 1's and 2's complement methods for addition and subtraction of signed binary numbers. It provides examples of how to represent positive and negative numbers using these complements and illustrates the addition and subtraction processes through various cases. Additionally, it briefly mentions floating point numbers and their representation in programming languages.

Uploaded by

nipun.datar
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)
8 views21 pages

Binary Arithmetic 1s and 2s complement

The document explains binary arithmetic, focusing on 1's and 2's complement methods for addition and subtraction of signed binary numbers. It provides examples of how to represent positive and negative numbers using these complements and illustrates the addition and subtraction processes through various cases. Additionally, it briefly mentions floating point numbers and their representation in programming languages.

Uploaded by

nipun.datar
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/ 21

BINARY ARITHMETIC

1’s and 2’s complement addition and subtraction


1’S COMPLEMENT REPRESENTATION
2’S COMPLEMENT REPRESENTATION

0110
1 (+)
0111
USE OF 1’S & 2’S COMPLEMENT
The main use is to represent a signed binary number.

In signed binary number - represent both positive and


negative numbers.

For representing the positive numbers, there is nothing to


do.

For representing the negative number, we first have to


represent it with a positive sign, and then we find the
corresponding complement of it.
EXAMPLE - +6 AND -6 (1’S COMPLEMENT)
+6
⚫ Binary equivalent of 6 is 0110
⚫ +6 is represented in the 5-bit as 0 0110
-6
⚫ +6=0 0110
⚫ Find the 1's complement of the number 0 0110, i.e., 1 1001.
EXAMPLE - +6 AND -6 (2’S COMPLEMENT)
+6
⚫ Binary equivalent of 6 is 0110
⚫ +6 is represented in the 5-bit as 0 0110
-6
⚫ +6=0 0110
⚫ Find the 2's complement of the number:
Find 1’s complement: 0 0110, i.e., 1 1001.
Add 1 to LSB 11010
ADDITION AND SUBTRACTION USING 1’S AND 2’S
COMPLEMENT
There are three different cases possible when we add two
binary numbers :
1. Addition of the positive number with a negative number
when the positive number has a greater magnitude
(Subtraction)
2. Adding a positive value with a negative value in case the
negative number has a higher magnitude (Subtraction)
3. Addition of two negative numbers
ADDITION AND SUBTRACTION USING 1’S
COMPLEMENT
1. ADDITION OF THE POSITIVE NUMBER WITH A
NEGATIVE NUMBER WHEN THE POSITIVE NUMBER HAS A
GREATER MAGNITUDE

Example: 1101 and -1001 (13 – 9 = 4)


First, find the 1's complement of the negative number
1001. The 1's complement of the number 1001 is 0110.
Now, add both the numbers
1101
0110 +
1 0011
We get the carry 1. We add this carry to the LSB
0011
1 +
0100
2. ADDING A POSITIVE VALUE WITH A NEGATIVE VALUE
IN CASE THE NEGATIVE NUMBER HAS A HIGHER
MAGNITUDE

Example: 1101 and -1110 (13 – 14 = -1)


First find the 1's complement of the negative number
1110. 1's complement of the number 1110 is 0001.
Now, add both the numbers
1101
0001 +
1110
Now, find the 1's complement of the result 1110 that is
the final result. 1's complement is 0001, and we add a
negative sign before the number so that we can identify
that it is a negative number.
3. ADDITION OF TWO NEGATIVE NUMBERS
Example: -1101 and -1110 (-13 – 14 = -27)
Firstly find the 1's complement of the negative numbers 01101 and
01110. 1's complement of the number 01110 is 10001, and 01101
is 10010.
Now, we add both the complement numbers
10001
+ 10010
1 00011
We add this end-around carry to the LSB of 00011.
00011
+ 1
00100
Now, find the 1's complement of the result 00100 that is the final
answer. So, the 1's complement of the result 00100 is 11011, and
add a negative sign before the number so that we can identify that
it is a negative number.
ADDITION AND SUBTRACTION USING 2’S
COMPLEMENT
1. ADDITION OF THE POSITIVE NUMBER WITH A
NEGATIVE NUMBER WHEN THE POSITIVE NUMBER HAS A
GREATER MAGNITUDE

Example: 1101 and -1001 (13-9=4)


First, find the 2's complement of the negative number
1001. The 2's complement of the number 1001 is 0111.
Now, add both the numbers
1101
0111 +
1 0100
We discard the carry 1. Answer is 0100
2. ADDING A POSITIVE VALUE WITH A NEGATIVE VALUE
IN CASE THE NEGATIVE NUMBER HAS A HIGHER
MAGNITUDE

Example: 1101 and -1110 (13 - 14 = -1)


First find the 2's complement of the negative number
1110. 2's complement of the number 1110 is 0010.
Now, add both the numbers
1101
0010 +
1111
Now, find the 2's complement of the result 1111 that is
the final result. 2's complement is 0001, and we add a
negative sign before the number so that we can identify
that it is a negative number.
3. ADDITION OF TWO NEGATIVE NUMBERS
Example: -1101 and -1110 (-13 - 14 = -27)
Firstly find the 2's complement of the negative numbers
01101 and 01110. 2's complement of the number 01110 is
10010, and 01101 is 10011.
Now, we add both the complement numbers
10010
+ 10011
1 00101
We discard the carry
Now, find the 2's complement of the result 00101 that is the
final answer. So, the 2's complement of the result 00101 is
11011, and add a negative sign before the number so that we
can identify that it is a negative number.
FLOATING POINT NUMBERS
Programming language supports decimal numbers.

Examples:
FLOATING POINT NUMBER REPRESENTATION
FLOATING POINT NUMBER REPRESENTATION
FLOATING POINT NUMBER REPRESENTATION
FLOATING POINT NUMBER REPRESENTATION
FLOATING POINT OPERATIONS

You might also like