How to Find Complement's Of Binary Numbers

 


1's complement and 2's complement are the way of representing the signed binary numbers.
In general, the binary number can be represented in two ways.

1- Unsigned Binary Numbers.
2- Signed Binary Numbers.

Unsigned Binary Numbers


unsigned binary number representation used for positive binary numbers can be represented. For n-bit unsigned binary numbers, all n-bits are used to represent the magnitude of the number. For example, if we represent decimal 12 in 5-bit unsigned number form then (12)₁₀ = (01100)₂. Here all 5 bits are used to represent the magnitude of the number. In unsigned binary number representation, using n-bits, we can represent the numbers from 0 to 2^n - 1. For example, using 4-bits we can represent the number from 0 to 15 in unsigned binary number representation.




Signed Binary Numbers


Using signed binary number representation both positive and negative numbers can be represented.

In signed binary number representation the most significant bit (MSB) of the number is a sign bit. For positive numbers, the sign bit is 0, and for negative numbers, the sign bit is 1. There are three different ways for signed binary numbers can be represented:

  1. Signed Magnitude Form
  2. 1’s Complement Form
  3. 2’s Complement Form

Sign Magnitude Representation


In sign-magnitude representation, the Most Significant bit of the number is a sign bit and the remaining bit represents the magnitude of the number in a true binary form. For example, if some signed number is represented in the 8-bit sign-magnitude form then MSB is a sign bit and the remaining 7 bits represent the magnitude of the number in a true binary form.



Here is the representation of + 34 and -34 in an 8-bit sign-magnitude form


Since the magnitude of both numbers is the same, the first 7 bits in the representation are the same for both numbers. For +34, the MSB is 0, and for -34, the MSB or sign bit is 1. In sign magnitude representations, there are two different representations for 0.




1's Complement in a Binary Number

a simple algorithm converts a binary number into the 1’s complement. If you want to generate 1’s complement out of a binary number, you can simply invert the number that you have. To get 1’s complement of a binary number, simply invert the given number. For example, 1’s complement of binary number 110010 is 001101.


Example 1: Find 1’s complement of binary number 10101110.

Solution

Simply invert each bit of a given binary number, so 1’s complement of a given number will be 01010001.

Example 2: Find 1’s complement of binary number 10001.001.

Solution

Simply invert each bit of the given binary number, so 1’s complement of the given number will be 01110.110.

Example 3: Find 1’s complement of 3-bit binary number.

Solution

Simply invert each bit of a given binary number, so 1’s complement of each 3-bit binary number will be,



2's Complement in a Binary Number

it is a simple algorithm for converting a binary number into a complement of 2’s. If you want to get a 2’s complement for any given binary number, you need to invert the number first. Then you can add 1 to the LSB (least significant bit) of the obtained result.


Example 1  Find 2’s complement of binary number 10101110.

Solution

Simply invert each bit of the given binary number, which will be 01010001. Then add 1 to the LSB of this result, i.e., 01010001+1=01010010 which is the answer.


Example 2  Find 2’s complement of binary number 10001.001.


Solution


Simply invert each bit of the given binary number, which will be 01110.110 Then add 1 to the LSB of this result, i.e., 01110.110+1=01110.111 which is the answer.



Why do we use One's and two's complements?

Because Computers don't know how to subtract numbers but computers can add two numbers. When we want to add a negative number then the problem will occur and the computer only can compute means it can do only addition operations that is why we use 1 and 2’s complement to change the negative value to the positive then the computer can perform addition operations.



Let us take another example with "Logic Kit" app this app is very easy and so good in these subjects of number systems.  Download This app from the app store for iOS  devices click here.

1- Open  the "Logic Kit" app 

2- Choose Find Complement

3- Select the base 2  

4- write the binary number that you need to find its complements


5- You see the solution then click on show steps to see the steps 



Example : Find the1's and 2's complements of (110011)







Previous Post Next Post

Contact Form