shift operator in java

There are three shift operators in Java: <<, >>, >>>, er, there is no <<<

<< is a bit shift left, one bit is shifted to the left for the binary of a number, the highest bit is discarded, and 0 is added to the lowest bit

>> and >>> are bit shifts to the right, both are shifted right by one bit, and the lowest bit is discarded. The difference is that for the highest bit, >> uses "sign extension". If the sign is positive, then add 0, and if the sign is negative, add 1 , >>> use "zero extension", no matter whether it is positive or negative, it is filled with 0


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326048337&siteId=291194637