Difference between 1's Complement representation and 2's Complement representation Technique - GeeksforGeeks

Difference between 1’s Complement representation and 2’s Complement representation Technique

Last Updated : 23 Apr, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Prerequisite – Representation of Negative Binary Numbers 

1’s complement of a binary number is another binary number obtained by toggling all bits in it, i.e., transforming the 0 bit to 1 and the 1 bit to 0. Examples:

Let numbers be stored using 4 bits

1's complement of 7 (0111) is 8 (1000)
1's complement of 12 (1100) is 3 (0011)

2’s complement of a binary number is 1 added to the 1’s complement of the binary number. Examples:

Let numbers be stored using 4 bits

2's complement of 7 (0111) is 9 (1001)
2's complement of 12 (1100) is 4 (0100)

  These representations are used for signed numbers.

The main difference between 1′ s complement and 2′ s complement is that 1′ s complement has two representations of 0 (zero) — 00000000, which is positive zero (+0), and 11111111, which is negative zero (-0); whereas in 2′ s complement, there is only one representation for zero — 00000000 (0) because if we add 1 to 11111111 (-1), we get 100000000, which is nine bits long. Since only eight bits are allowed, the left-most bit is discarded(or overflowed), leaving 00000000 (-0) which is the same as positive zero. This is the reason why 2′ s complement is generally used.

Another difference is that while adding numbers using 1′ s complement, we first do binary addition, then add in an end-around carry value. But, 2′ s complement has only one value for zero and doesn’t require carry values.

Range of 1’s complement for n bit number is from -2n-1-1 to 2n-1-1 whereas the range of 2’s complement for n bit is from -2n-1 to 2n-1-1.

There are 2n-1 valid numbers in 1’s complement and 2n valid numbers in 2’s complement.

Difference between 1’s Complement representation and 2’s Complement representation in tabular form:

           Criteria                          1’s Complement                                  2’s Complement
Definition The 1’s complement of a binary number is obtained by inverting all its bits. The 2’s complement of a binary number is obtained by adding 1 to the 1’s complement of the number.
Range of values that can be represented with n bits From -2^(n-1) + 1 to 2^(n-1) – 1 From -2^(n-1) to 2^(n-1) – 1
Number of representations for zero Can be represented in two ways (all 0s and all 1s). Can be represented in only one way (all 0s).
Addition of positive and negative numbers Same as unsigned binary addition. Same as unsigned binary addition.
Subtraction of numbers Subtract the smaller number from the larger one, then add a sign bit to the result. Add the negative number to the positive one using binary addition.

Previous Article
Next Article

Similar Reads

Difference between Substitution Cipher Technique and Transposition Cipher Technique
Both Substitution cipher technique and Transposition cipher technique are the types of Traditional cipher which are used to convert the plain text into cipher text. Substitution Cipher Technique: In Substitution Cipher Technique plain text characters are replaced with other characters, numbers and symbols as well as in substitution Cipher Technique
3 min read
Check if binary representation of a given number and its complement are anagram
Given a positive number you need to check whether it's complement and the number are anagrams or not.Examples: Input : a = 4294967295 Output : Yes Binary representation of 'a' and it's complement are anagrams of each other Input : a = 4 Output : No Simple Approach: In this approach calculation of the complement of the number is allowed.1. Find bina
9 min read
Difference between Backtracking and Branch-N-Bound technique
Algorithms are the methodical sequence of steps which are defined to solve complex problems. In this article, we will see the difference between two such algorithms which are backtracking and branch and bound technique. Before getting into the differences, lets first understand each of these algorithms. Backtracking: Backtracking is a general algor
4 min read
Difference between Signed magnitude and 2's complement
1. Signed Magnitude Method : In the signed magnitude method number is divided into two parts: Sign bit and magnitude. Sign bit is 1 for negative number and 0 for positive number. Magnitude of number is represented with the binary form of the number. Example: Lets take 8 bits register. 2. 2's Complement Method : In 2's complement method, positive nu
2 min read
Difference Between Presentation and Representation
In various contexts, especially in the fields of computer science, communication, and cognitive sciences the terms "presentation" and "representation" are frequently used. While they may seem similar they have distinct meanings and implications. In various contexts, especially within the realms of art, communication, and academia, the terms "presen
3 min read
8085 program to find 1's and 2's complement of 8-bit number
Problem - Write a program to find 1's and 2's complement of 8-bit number where starting address is 2000 and the number is stored at 3000 memory address and store result into 3001 and 3002 memory address. Example - Algorithm - Load the data from memory 3000 into A (accumulator)Complement content of accumulatorStore content of accumulator in memory 3
2 min read
8085 program to find 1’s and 2’s complement of 16-bit number
Prerequisite - 8085 program to find 1’s and 2’s complement of 8-bit number Problem - – Write a program to find 1’s and 2’s complement of 16-bit number where starting address is 2000 and the number is stored at 3000 memory address and store result into 3002 and 3004 memory address. Example - Algorithm - Load a 16-bit number from memory 3000 into a r
2 min read
Interface 8255 with 8085 microprocessor for 1’s and 2’s complement of a number
Introduction : The 8255 is a programmable peripheral interface chip that can be interfaced with the 8085 microprocessor to perform various input/output operations. One of the operations that can be performed using the 8255 and the 8085 microprocessor is finding the 1's and 2's complement of a number. The 1's complement of a binary number is obtaine
4 min read
1's and 2's complement of a Binary Number
Given a Binary Number as a string, print its 1's and 2's complements. 1’s complement of a binary number is another binary number obtained by toggling all bits in it, i.e., transforming the 0 bit to 1 and the 1 bit to 0.In the 1's complement format , the positive numbers remain unchanged . The negative numbers are obtained by taking the 1's compleme
9 min read
8085 program to find 2's complement of the contents of Flag Register
Problem – Write an assembly language program in 8085 microprocessor to find 2's complement of the contents of Flag Register. Example - Algorithm – Initialize the value of Stack Pointer (SP) to 3999 Push the contents of PSW (Register pair formed by Accumulator and Flag Register) into the memory stack Pop the contents from the stack into register pai
2 min read