posted 18 years ago
First I was afraid too...I also couldn't understand the whole shifting thing..
But its sooo easy once you try and code something..
Maybe you can specify your question?!
First of all, you can only shift integral values (int,long)
(You can shift narrower types too, but the operation is always at least performed on int)
right shift (>> ) shifts the bit-representation of the value to the right and fills the resulting "empty space" on the left side with the value of the most significant bit before the shift (the leftmost), so it's a "signed shift", cause if the leftmost bit was 1 (negative) before the shift, it will be negative after the shift..(value is divided by 2 on a shift by 1)
left shift(<< ) shifts to left, and the right side will be filled with zeros(0)..(value is multiplied by 2 on a shift by 1)
unsigned right shift (>>> ) shifts to right, but always fills the space with zeros..
But maybe you dont understand the whole binary 1 and 0 thing?
Regards,
Flom
[ May 26, 2006: Message edited by: Flom Xanther ]
[ May 26, 2006: Message edited by: Flom Xanther ]