Signed Number Systems

Signed Number System

In signed number systems, a number is represented with two parts; one the sign bit, and the rest bits denote the magnitude of the number. Signed number are represented using the following representation:

  1. Sign and Magnitude number system:
  2. 1’s complement Number System
  3. 2’s Complement Number System

Sign and Magnitude number system

In this system, the MSB is set to 0(zero) to indicate +ve number and is set to 1(one) to indicate the -ve number. Signed numbers are represented as:

Figure-1: sign-and-magnitude

Complete the following Table

+7 Sign Magnitude
+7 0 1 1 1
-6 1 1 1 0
+25
-24
+14
-15
-10
+0
-0

Complement method:

Complement of a number: Complement of a number is done to represent its -ve / or positive representation. Thus the complement of a +ve number is the -ve number, and complement of -ve number is +ve number. There are different types of -ve number representation using complement method:

a.  1’s Complement System
b.  2’s Complement System
c.  9’s Complement System
d.  10’s Complement System
e.  r’s  and (r-1)’s Complement System

1’s Complement System:

Obtained by complementing each bit including the sign bit(MSB). It can also be obtained by subtracting the binary equivalent of the given number from all 1’s.

Decimal

1’s Complement

+0 0 0 0 0
+1 0 0 0 1
+2 0 0 1 0
+3 0 0 1 1
-0 1 1 1 1
-1 1 1 1 0
-2 1 1 0 1
-3 1 1 0 0

Example: 
  Represent -56 in 1’s complement system
+56=0111000
-56= 1000111 (by complementing each bit of +56)
or subtract the binary number from binary all 1’s as given below

  1111111

-0111000
————-
1000111
————–

2’s Complement System:
2’s complement is obtained by taking 1’s complement and adding 1 to it.

examples

-2  =   1’s complent of +2  and adding 1 to it

=     (0010)’

1101

+ 1

——————–

1101 =-2

——————–

2’s Complement Code

Deimal Sign Magnitude
+0 0 0 0 0
+1 0 0 0 1
+2 0 0 1 0
+3 0 0 1 1
-0 0 0 0 0
-1 1 1 1 1
-2 1 1 1 0
-3 1 1 0 1

Advantage of 2’s complement:

There only one code for +0 and -0

Addition and subtraction becomes easy

Represent -56 in 2’s complement system

+56= 0111000

1’s complement of +56 is obtained by complementing each bit of +56. So

-56=  1000111 (in 1’s complement)

 2’s Complement= 1’s complement + 1

Therefore, -56 = 1000111+ 1= 1001000

or

 1111111

-0111000 (subtract binary of +56) from all 1s
————-
1000111
+1 ( Add 1 to get the 2’s complement )
————–
1001000 ( this is the 2’s complement representation of -56)
————

9’s Complement System:
9’s complement is obtained by taking subtracting the given decimal/or BCD) from a number of all 9’s.
Ex. : Represent -7656 in 9’s complement system

  99999

– 07656 (subtract binary of +56 from all 9s)
————-
92343 ( This is the 9’c complement representation of -7656).

10’s Complement System:

10’s complement is obtained by taking 9’s complement and adding 1 to it.
Ex. : Represent -7656 in 10’s complement system

     99999

  – 07656 (subtract binary of +56 from all 9s
————-
92343
+       1    ( Add 1 to get the 10’s complement )
————–
92344 ( this is the 10’s complement representation of -7656)
————

(r-1)’s Complement System:

In general the (r-1)’s complement of a number is obtained as follows:
subtract the given number from rn+1 – 1; where n is the number of digits in the given number and r is the base of the given number system.

r’s Complement System:

In general the r’s complement of a number is obtained as follows:
subtract the given number from rn+1 – 1 and add 1 to the result. Here n is the number of digits in the given number and r is the base of the given number system.

Range of numbers

 

  Number system-> Sign &  Magnitude 1’s  Complement 2’s Complemet
 Range +/- 0 to +/-  2n-1 – 1 +/- 0 to  +/-  2n-1 – 1 -1 to – 2n-1
0 to  + 2n-1 – 1

Numericals:
Add  +65 and -26; +12 and -15 using 1’s and 2’s complement

  1. code the two number with equal number of  bits

+26   = 00011010

+65  =01000001

1’s  complement of +26 = -26 = 11100101

-26 =+ 11100101

+65  = 01000001

Add          1                -> Carry

   00100110

Add the carry+1

Therefore (65-26) =00100111 which is + 39

  1. Explain the concept of underflow and Overflow in different number systems
    Overflow: If the range of number exceeds the size of the number, we say that their is an overflow:
    If the size of the register is 4 bit, and if the addition of two numbers results in a number greater than 16 for an unsigned number or greater than 8 for signed number. The exact value is given in following table:
Sign &  Magnitude 1’s  Complement 2’s Complemet
Maximum  allowable range +/- 0 to +/-  2n-1 – 1 +/- 0 to  +/-  2n-1 – 1 -1 to – 2n-1Â
0 to  + 2n-1 – 1
Overflow Result  > + 2n-1 – 1 Result  > + 2n-1 – 1 Result  > + 2n-1 – 1
Underflow Result  < – 2n-1 – 1 Result  < – 2n-1 – 1 Result  <  – 2n-1

Examples:
Consider two 4 bit numbers to be added are + 3 and + 5, the result after addition as we know will be = +8 = 1000, but .

Sign &  Magnitude 1’s   Complement 2’s Complemet
+3 = 0011
+5 = 0101
=  1000
Overflow
Result > +  24-1– 1 Also we note that the addition of +ve numbers results in a –ve number (MSB=1)
Overflow
Result > +  24-1 – 1 Also we note that the addition of +ve results in a –ve number (MSB=1)
Overflow
Result > +  24-1 -1 Also we note that the addition of +ve numbers results in a –ve number (MSB=1)
  1. Underflow Example:

If the result of additional / subtraction results in a number that is smaller than the one that can be represented in a given size of register

Consider two 4 bit numbers as -3 and 5, on subtracting 5 from -3 we get the answer = -8 , which is (11000) in sign and magnitude and  requires 5 bits,  and 10111 in 1’s complement system and 1000 in 2’s complement system, so looking at the range of various representation we conclude as stated in table below:

Sign &  Magnitude 1’s  Complement 2’s Complemet
Underflow Result  < – 2n-1 – 1 Result  < – 2n-1 – 1  Result  <  – 2n-1
For 4 bit  number the result of add/sub should be : <  -7  <  – 7  <  -8
-3-5=-8 Underflow Underflow Within  RanUnderflow

 

How to find an Overflow: 

 

Check the MSB and the carry bit, if there is a carry in to the MSB bit but no carry out of MSB then there is an overflow. i.e. The XOR of MSB and Carry will give the status of overflow:
MSB (xor) Carry = 0 No overflow

MSB (xor) Carry = 1 , then there is an overflow.

 

Updated: August 6, 2019 — 4:11 pm

Leave a Reply

Your email address will not be published. Required fields are marked *

care4you © 2014 care4you © Revision-1: 2016 care4you © Revision-2: 2019 Connect On Facebook DMCA.com Protection Status
error: Content is protected !!