[ILUG-BOM] doubt

Goldwyn Rodrigues goldwyn_r@[EMAIL-PROTECTED]
Fri Oct 5 20:26:02 IST 2001


You r right when u say that right shift divides the number by 2(by putting a
zero). But in case of a negative number, it stores the value in the form of
2's complement. and hence the first bit is 1 (for -ve). So when u right
shift, u add a zero (unconditionally) converting the number to positive.

I read this in a Computer Organization and Architecture book by William
Stallings and not in a C book.

Goldwyn :o)



>
> Hello friends,
>        Applying the right shift operator in c  to a number and shifting it
right by a single digit is equivalent to dividing that numer by 2.But if the
number is negative then it is not equivalent.how come?
> please give me information about the books in which i can find an
explaination.
> Thanks ,
> Praveen.
>





More information about the Linuxers mailing list