Detection of "Overflow" of negative numbers e.g. -2(1 10) , -4 (1 100) etc.

Discussion in 'Math' started by lemuel rapsuk, Sep 1, 2006.

  1. lemuel rapsuk

    Thread Starter New Member

    Sep 1, 2006
    Respected Sir,
    Subject: Detection of "Overflow" in "arithmetic left shift" of negative numbers e.g.
    -2 (that is 110) etc. if it is stored in a 3-bit register
    -4 (that is 1100) etc. if it is stored in a 4-bit register
    -8 (that is 11000) etc. if it is stored in a 5-bit register

    Why is it that when I face a problem regarding detection of "Overflow"when I perform an "arithmetic left shift" of a negative number whose 2's complement representation is the same as the positive number in binary
    e.g. -2 is 110(where 1 om the Left Most position is used as the Sign bit)
    e.g. -4 is 1100
    {that is negative numbers:
    (a) which starts with a ONE
    and (b) whose remaining bits are all ZEROES e.g. 10, 100, 1000}

    As per M Morris Mano's "Computer System Architecture", the overflow is detected by taking the EX-OR of the Sign bit (Rn-1) and the Most Significant Bit (Rn-2) of the number. If the EX-OR operation yields a One, then Overflow occurs. As far as other Numbers like -3,-5,etc as well as positive numbers, I do not face any problem with detecting overflow. But for the numbers that I mentioned before like -2, -4, etc. (10, 100 etc), I find that the EX-OR operation does not indicate an overflow
    e.g. please see below
    The number Minus 2, if it is stored in a 3-bit register is represented as 1 10.
    The two ones in Rn-1 and Rn-2(are both same viz. both are Ones) indicate that EX-OR = 0 , which implies "NO Overflow". But in reality there is an overflow- provided the register used is only 3-bit in size.

    Similarly, the number Minus Four is represented by 1 100 in a 4-bit register. As per the EX-OR function, there is "No Overflow". But the fact is that there is an overflow.
    So that means that M Morris Mano's condition for detection of the overflow is not true for this type of numbers(e.g. 1 10, 1 100 etc). There numbers I perceive, are part of "Exceptional cases". So how do I check for such overflows?
    Please Sir, kindly help me in clarifying this matter.
    Looking forward to receiving your enlightenment regarding this.
    Thank you
    Lemuel Rapsuk
    Instructor("Computer Organisation and Architecture")
    St. Anthony's College, Shillong
    North East India