Java left shift <<&>> right shift &>> unsigned right shift

Source: Internet
Author: User

The difference between right-shift operator >> and unsigned right-shift operator >>> in Java

In making a PCM audio encountered this character, but I see some of the Baidu's interpretation of the place can not make me very understand, so I sorted.

First, the difference between left and right shifts is well differentiated.

Shift left << : That is, the number corresponds to the total left of the binary code, left out of the partial discard, 0 on the right. For example: 253 of the binary code of11 1101, after the operation 253<<2 to get 1111 0100. It's simple .

Shift Right >> : the number corresponding to the binary code of the whole right shift, the left side with the original flag is added, the right part of the excess to discard.

Unsigned right shift >>> : Regardless of the positive or negative flag bit is 0 or 1, the number of binary code to move the whole right, the left part is always filled with 0, the right part is discarded.

Example comparison:

-5 in binary notation 1111 1011 , red for that number flag bit

-5>>2: 1111 1011-------------->1110 .

11 for the flag bit

-5>>>2: 1111 1011-------------->xx1110 .

00 for the supplement of 0

Java left shift <<&>> right shift &>> unsigned right shift

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.