Java right-shift operators >> and >>>

Source: Internet
Author: User
Tags bitwise
Java provides two right-shift operators, which belong to bit operators. The bitwise operator is used to manipulate the bits. >>: Arithmetic Right shift operator, also known as symbol right shift. Fill the left empty space with the top >>>: Logical Right Shift operator, also known as unsigned Right shift. To operate on bits only, fill the left empty space with 0. The expression is: R = e1 >> E2;r = E1 >>> E2; Moves the number E1 right to the E2 bit. Operation rules:>>: In binary form, all the numbers to the right to move the corresponding number of digits, low-off (discard), high position of the vacancy complement the sign bit, that is, positive complement 0, negative complement 1. The sign bit does not change. >>>: In binary form, all numbers are shifted to the right by the corresponding number of digits, the lower position is removed (discarded), and the upper slot is 0. For positive numbers, it is the same as a signed right shift, which is different for negative numbers. Press Previous, 1 is represented in 32-bit binary as: 11111111 11111111 11111111 11111111-1>>1: Bitwise right SHIFT, symbol bit unchanged, still get
11111111 11111111 11111111 11111111 Therefore the value is still-1 and the result of -1>>>1 is 01111111 11111111 11111111 11111111

Java right-shift operators >> and >>>

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.