Bitwise Right Shift Operators in Java Last Updated : 08 Mar, 2023 Comments Improve Suggest changes Like Article Like Report Try it on GfG Practice In C/C++ there is only one right shift operator '>>' which should be used only for positive integers or unsigned integers. Use of the right shift operator for negative numbers is not recommended in C/C++, and when used for negative numbers, the output is compiler dependent. Unlike C++, Java supports following two right shift operators. Here we will be discussing both of right shift operators as listed: Signed right shift ">>"Unsigned right shift ">>>"Type 1: Signed Right Shift In Java, the operator '>>' is signed right shift operator. All integers are signed in Java, and it is fine to use >> for negative numbers. The operator '>>' uses the sign bit (leftmost bit) to fill the trailing positions after the shift. If the number is negative, then 1 is used as a filler and if the number is positive, then 0 is used as a filler. For example, if the binary representation of a number is 10....100, then right shifting it by 2 using >> will make it 11.......1. Example: Java // Java Program to Illustrate Signed Right Shift Operator // Main class class GFG { // Main driver method public static void main(String args[]) { int x = -4; System.out.println(x >> 1); int y = 4; System.out.println(y >> 1); } } Output-2 2Type 2: Unsigned Right Shift Operator In Java, the operator '>>>' denotes unsigned right shift operator and always fill 0 irrespective of the sign of the number. Example: Java // Java Program to Illustrate Unsigned Right Shift Operator // Main class class GFG { // main driver method public static void main(String args[]) { // x is stored using 32 bit 2's complement form. // Binary representation of -1 is all 1s (111..1) int x = -1; // The value of 'x>>>29' is 00...0111 System.out.println(x >>> 29); // The value of 'x>>>30' is 00...0011 System.out.println(x >>> 30); // The value of 'x>>>31' is 00...0001 System.out.println(x >>> 31); } } Output7 3 1 Time Complexity: O(1). Space Complexity: O(1) as no extra space has been used. Comment More infoAdvertise with us Next Article Bitwise Right Shift Operators in Java K kartik Follow Improve Article Tags : Bit Magic Java DSA Java-Operators Practice Tags : Bit MagicJavaJava-Operators Similar Reads Bitwise Operators in Java In Java, Operators are special symbols that perform specific operations on one or more than one operands. They build the foundation for any type of calculation or logic in programming.There are so many operators in Java, among all, bitwise operators are used to perform operations at the bit level. T 6 min read Shift Operator in Java Operators in Java are used to performing operations on variables and values. Examples of operators: +, -, *, /, >>, <<. Types of operators: Arithmetic Operator,Shift Operator,Relational Operator,Bitwise Operator,Logical Operator,Ternary Operator andAssignment Operator. In this article, w 4 min read Left Shift Operator in Java The decimal representation of a number is a base-10 number system having only ten states 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. For example, 4, 10, 16, etc. The Binary representation of a number is a base-2 number system having only two states 0 and 1. For example, the binary representation of 4, a base- 4 min read Bitwise Operators in C In C, bitwise operators are used to perform operations directly on the binary representations of numbers. These operators work by manipulating individual bits (0s and 1s) in a number.The following 6 operators are bitwise operators (also known as bit operators as they work at the bit-level). They are 6 min read Basic Operators in Java Java provides a rich operator environment. We can classify the basic operators in java in the following groups: Arithmetic OperatorsRelational OperatorsBitwise OperatorsAssignment OperatorsLogical Operators Let us now learn about each of these operators in detail. 1. Arithmetic Operators: Arithmetic 10 min read Like