3. Data Representation for
Computation
The most common representation is 2’s
Complement Notation. It is discussed Next:
Positive numbers are represented as the case with
signed number, but negative numbers are
represented in 2’s complement form
This is an efficient method for simple binary
addition and subtraction.
3
4. 2’s Complement Notation
Positive integers have it’s sign bit as 0
Negative integers are represented as a 2’s
Complement.
What is a Complement?
English Meaning: Balance to make a group
complete.
4
5. Example – 1’s and 2’s Complement for 8 bit numbers
(Please note first digit is sign bit)
Decimal
Number
Equivalent Binary
Place
Value
Sign Bit
(0/1)
26 =
64
25 =
32
24 =
16
23 =
8
22=
4
21 =
2
20 =
1
+37 Value 0 0 1 0 0 1 0 1
-37 1’s 1 1 0 1 1 0 1 0
-37 2’s 1 1 0 1 1 0 1 1
•First find the magnitude of the Number in Binary as
Positive Number (+37)
•Complement each bit (1 by 0) and (0 by 1) to make 1’s
complement of the negative number (-37)
•Add 1 to 1’s complement to get 2’s complement of (-37)
5
6. Example 2
Decimal
Number
Equivalent Binary
Place
Value
Sign Bit
(0/1)
26 =
64
25 =
32
24 =
16
23 =
8
22=
4
21 =
2
20 =
1
+100 Value 0 1 1 0 0 1 0 0
-100 1’s 1 0 0 1 1 0 1 1
Add 1 c=1 c=1 1
-100 2’s 1 0 0 1 1 1 0 0
•Magnitude of the Number in Binary (+100)
•Complement each bit to get 1’s complement of (-100)
•Add 1 to 1’s complement to get 2’s complement of -100).
Please note the carry bit on addition shown in Orange. 6
7. Conversion of Binary Integers to 2’s
Complement Notation
For positive integers – no change is needed
For negative integers
Method 1: Complement all the bits individually and
then add 1 to resultant, for instance complement of
65 will be:
+68 in binary (using 8 bits) 0100 0100
- 68 will be obtained as 1011 1011 + 1
= 1011 1100
Method 2: Moving from least significant bit, leave all
bits till the first 1 as it is, then complement all the
remaining bits
7
8. Addition using 2’s Complement
Notation
Four Cases:
Addition of two positive integers:
+68 0 100 0100
+38 0 010 0110
------------------------
+106 0 110 1010
------------------------
8
9. Addition using 2’s Complement
Notation
Addition of one positive and one negative
integer (the positive integer is greater):
+68 0 100 0100
-38 1 101 1010
------------------------
+30 1 0 001 1110
------------------------
Carry in to sign bit = Carry out of Sign bit
=> NO OVERFLOW - ignore the carry out of sign bit
9
10. Addition using 2’s Complement
Notation
Addition of one positive and one negative
integer (the positive integer is smaller):
-68 1 011 1100
+38 0 010 0110
------------------------
-30 1 110 0010
------------------------
+30 0 001 1110
10
13. Check Your Progress
Using an 8 bit representation perform the
following additions:
Add +92 with -85
Add -75 and -53
Add -92 and -39
Add +34 and -65
Add 75+53
You must indicate overflow, if any.
13
14. Queries
For queries please send mail to specified email id
in the Programme Guide
14