recategorized by
1,208 views
1 votes
1 votes
Represent +42 and -42 in sign-magnitude, 1’s complement and 2’s complement

representation. Find the result of 42 - 20 using 2’s complement.
recategorized by

1 Answer

1 votes
1 votes

Consider that we have 8 bits to represent the number. The binary representation of $42$ is $00101010$.

  1. In sign-magnitude form, the MSB is used to represent the sign bit and remaining bits represent the magnitude. So $+42$ is represented as:
0 0 1 0 1 0 1 0

and $-42$ is represented as:

1 0 1 0 1 0 1 0

 

  1. In 1’s complement form:
    1. If the number is +ve, convert it to binary and make its length to the given bit size. +42 is represented as $\textbf{00101010}$.
    2. If the number is -ve, the representation is simply the 1’s complement of that number. So the 1’s complement representation of $00101010$ is :
1 1 0 1 0 1 0 1

 

  1. In 2’s complement form:
    1. If the number is +ve, convert it to binary and make its length to the given bit size. +42 is represented as $\textbf{00101010}$.
    2. If the number is -ve, the representation is simply the 2’s complement of that number. So the 2’s complement representation of $00101010$ is : 

       (1’s complement of 00101010) + 1= (11010101 + 1) =

1 1 0 1 0 1 1 0

 

Note: If the number is +ve: sign-magnitude, 1’s complement and 2’s complement representation are all same.


 

To perform the subtraction $42 – 20$ in 2’s complement , we simply add 42 with 2’s complement of 20.

$42 – 20 = 00101010 + 2’s(00010100) = 00101010 + (11101100) = 1 00010110$.

  1. If the resultant has a carry, the answer is +ve and we discard the carry.
  2. If the resultant has no carry, the answer is -ve and to get the final value, we simply find the 2’s complement of the answer.

In this case, we have a carry, so just discard it. Value becomes $+(00010110)_2 = \textbf{+22}$

edited by

Related questions

1 votes
1 votes
1 answer
2
Arjun asked Feb 16
1,585 views
Which of the following is/are EQUAL to $224$ in radix - $5$ (i.e., base - $5$) notation?$64$ in radix -10$100$ in radix -8$50$ in radix -16$121$ in radix -7
3 votes
3 votes
1 answer
3