Java Unsigned Right Shift
In this chapter you will learn:
Description
Java's unsigned, shift-right operator, >>>
, always shifts zeros into the
high-order bit.
Syntax
Its general form is shown here:
value >>> num
num
specifies the number of positions to right-shift.
Example
The following code shows how to use unsigned right shift.
public class Main {
public static void main(String[] argv) {
int a = -1;//from w w w. j av a 2 s . co m
a = a >>> 24;
System.out.println("a is " + a);
}
}
The output:
Next chapter...
What you will learn in the next chapter:
- How to use the ternary ? Operator
- Syntax for Java ternary operator
- Example - Java ternary operator
- Example - obtain the absolute value of a variable.