You are on page 1of 9

• There are three formats for representing

negative numbers in base-r system


• Sign-magnitude
• r’s complement
Given a number N in base r having n digits, the
(r)’s complement of N is defined by = (rn) -N.
For example working on 4 digits:
The 10’s complement of 7 is 104 – 7 = 9993
The 10’s complement of 25 is 104 – 25 = 9975
The 10’s complement of 425 is 104 – 425 = 9575
104–7= 1+9999-7= (1+9999)-7= 1+(9999-7)= 1+9992= 9993
104–425= 10000-425= 1+9999-425= 1+(9999-425)= 1+9574= 9575
10’s complement of 864 → 1+(9135)= 9136
Subtract 55-33 = ? 22
4-digits
Subtract 0055-0033 = ?
10’s complement of 0033= 1+9966=9967

55-33 → 0055+9967 = 10022 = 22


55-33 → 55+(10000-33) = 10022 = 10000 + 22 →22
4-digits
Subtract 777-444= ? 333

Subtract 0777 - 0444 = ?

The leftmost digit in positive number is ZERO

0777-0444= 0777 + 9556 = 10333 → 0333


4-digits
Subtract 444 -777 = ? -333

Subtract 0444 -0777 = ?

The most left digit in positive number is ZERO

0444-0777= 0444 + 9223 = 9667

10’s complement of 9667 is 1+0332 = 0333 →-333


Given a number N in base r having n digits, the
(r)’s complement of N is defined by = (rn) -N.
For example if n= 4bits:
The 2’s complement of (0010)2 is 24 – 2 = 14 = (1110)2
The 2’s complement of (0110)2 is 24 – 6 = 10 = (1010)2

24– 6 = 16-6 =
= (1+ 15)-6
= 1+(15-6)= 1+(1111)2 –(0110)2= 1 + (1001)2=(1010)2
Decimal 4bit (+ve) 4bit (-ve)

1 0001 1111
2 0010 1110
3 0011 1101
4 0100 1100
5 0101 1011
6 0110 1010
7 0111 1001

Weights of 2’s complement (3 bit ) are : -4 2 1


Weights of 2’s complement (4 bit ) are : -8 4 2 1
Weights of 2’s complement (n bit ) are : -2n-1 2n-2 2n-3 … 21 20
Ex using 2’s complement (1010)2 is -8 +2 = -6
Example (using 2’s complement)
( 1 0 0 1)2 → -8+1= -7
( 0 1 0 1)2 → 4+1 = 5
(1 0 1)2 → -4+1 = -3
(0 1 1)2 → 1+2= 3

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Using 2’s complement (4-bits)
Max → (0111)2 = +7
Min → (1000)2 = -8
Using 2’s complement (3-bits)
Max → (011)2 = +3
Min → (100)2 = -4
Using 2’s complement (n-bits)
Max → +(2n-1)-1
Min → -(2n-1)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

You might also like