1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

shift operation on a negative number.

Discussion in 'C' started by avee137, Sep 2, 2010.

  1. avee137

    avee137 New Member

    Joined:
    Sep 2, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    please explain shift operation on negative numbers.
    i executed a demo as below:
    Code:
    char c=-1,d,e;
    d=c9;
    it yields d=0 ,which i could understand as it works like a normal shift operation where bits are discarded as they move out of the word and bits on right side get filled by all 0's,

    and e=-1,
    and this i could not figure out as even after shifting it by 9 bits it holds the value intact.


    any relevant explanation or reference would be a great help.
     
  2. techgeek.in

    techgeek.in New Member

    Joined:
    Dec 20, 2009
    Messages:
    572
    Likes Received:
    17
    Trophy Points:
    0
    Occupation:
    EOC (exploitation of computers)..i m a Terminator.
    Location:
    Not an alien!! for sure
    Home Page:
    how is it possible if it is thought from a variable point of view?? computer does not discriminate between c and e... variable can be anything...can you post a full proof code so that i can test that in my system...?
     

Share This Page