I'm practising for the SCJP exam using cram notes from the Internet.
According to my notes the >>
operator is supposed to be signed right shift, with the sign bit being brought in from the left. While the left shift operator <<
is supposed to preserve the sign bit.
Playing around however, I'm able to shift the sign with the <<
operator (f.e. Integer.MAX_VALUE << 1
evaluates to -2
, while I'm never able to shift the sign with the >>
operator.
I must be misunderstanding something here, but what?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…