in Digital Logic retagged by
150 views
0 votes
0 votes
Explain out of Sign magnitude , 1’s complement and 2’s complement,
in Digital Logic retagged by
by
150 views

1 Answer

0 votes
0 votes

Important points –

  • Computer hardware does not know if $(1010)_2$ is 10 or -2 or some other number.
  • The user has to specify the DATA FORMAT, based on which it will be decided whether $(1010)_2$ is 10 or -2 or some other number.

Let’s assume we are dealing with 3 bit data only.

Sign magnitude data format → 

MSB serves as sign and rest bits as magnitude so => 101 will be – 1

000 →  +0
001 →  +1
010 →  +2
011 →  +3
100 →  – 0
101 →  – 1
110 →  – 2
111 →  – 3

Here we see that for n=3 range of numbers that we can represent is -3 to +3 => $-2^{n-1}-1$ to $+2^{n-1}-1$
But the problem is that 0 is represented twice. This is why sign magnitude is not used as a data format to actually represent numbers.

1’s Complement data format → 

MSB serves as sign. If sign is +ve (MSB is 0) then DON’T take 1’s complement. If sign is -ve (MSB is 1) then magnitude is 1’s complement of the total binary number.
Eg : 010 is +2 but 110 is -1 [-ve sign since MSB is 1 and then 1’s complement of 110 is 1 so magnitude will be 1]

000 →  +0
001 →  +1
010 →  +2
011 →  +3
100 →  – 3
101 →  – 2
110 →  – 1
111 →  – 0

Here also, we see that for n=3 range of numbers that we can represent is -3 to +3 => $-2^{n-1}-1$ to $+2^{n-1}-1$
Here too the problem is that 0 is represented twice. This is 1’s complement is not used as a data format to actually represent numbers.

2’s Complement data format → 

MSB serves as sign. If sign is +ve (MSB is 0) then DON’T take 2’s complement. If sign is -ve (MSB is 1) then magnitude is 2’s complement of the total binary number.
Eg : 010 is +2 but 110 is -2 [-ve sign since MSB is 1 and then 2’s complement of 110 is 2 so magnitude will be 2]

000 →  +0
001 →  +1
010 →  +2
011 →  +3
100 →  – 4
101 →  – 3
110 →  – 2
111 →  – 1

Here we see that for n=3 range of numbers that we can represent is -4 to +3 => $-2^{n-1}$ to $+2^{n-1}-1$
Also there is no redundancy. Hence this data format can be used to represent numbers.
 

MORE INFO →

  • Unsigned number representation is just the magnitude of the binary number → so for unsigned numbers range is $0$ to $2^{n}-1$.
  • All of these discussed above come under fixed point data format. And none of these can be used to represent decimal numbers. So unsigned integer would use UNSIGNED data format. Signed integer would use 2’s COMPLEMENT data format. But for representing decimal numbers in memory, we would need FLOATING POINT DATA FORMAT.
  • To increase accuracy, in case of fixed point data format, the CPU data size will have to be increased. 

Related questions