Why doesn't Java support the <<<
(unsigned left shift) operator, but does support the >>>
(unsigned right shift) operator?
相关问题
- Delete Messages from a Topic in Apache Kafka
- how to define constructor for Python's new Nam
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
I think this is a design mistake. The << is not arithmetic shift. << is supposed multiply 2 if you do
it return a positive number! a negative number multiply 2 should never get a positive number. the << is doing <<< work.
Because a (hypothetical) unsigned left shift operator would do exactly the same thing as the existing left shift operator.
(Hint: multiplying a binary integer by 2 entails left shifting by 1 and making the rightmost bit zero whether the integer representation is signed or unsigned. Write some examples on a piece of paper and test it for yourself.)
That is because when you left shift the bits , the leftmost bit (AKA SIGNED Bit) is lost anyways.
Since unsigned left shift operator would do exactly the same thing as the existing left shift operator, we don't have it.
from Shifts in Java...