I found this java question on the internet and had some questions about it.
Which statements are accurate:
- a) >> performs signed shift while >>> performs an unsigned shift.
- b) >>> performs a signed shift while >> performs an unsigned shift.
- c) << performs a signed shift while <<< performs an unsigned shift.
- d) <<< performs a signed shift while << performs an unsigned shift.
I'm a little unsure what a signed shift is, does it mean that it retains the sign of the binary number regardless of what happens in the shift itself (which would make the most sense to me) or does it mean that the MSB does not change unless it is overwritten in the shift operation itself.
so
- a) true: regardless of how many shifts using >> you make, the MSB is always retained as its original therefore signed? Whereas >>> will always overwrite the MSB with a 0, and therefore unsigned ?
- b) false, because of above explanation
- c) not sure, because the first bit could be overwritten with the << shift operation and therefore doesn't retain its sign?
- d) not sure again.