Java Unsigned Right Shift

In this chapter you will learn:

  1. What is Unsigned Right Shift
  2. Syntax for Unsigned Right Shift
  3. Example - Unsigned Right Shift

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:

  1. How to use the ternary ? Operator
  2. Syntax for Java ternary operator
  3. Example - Java ternary operator
  4. Example - obtain the absolute value of a variable.
Home »
  Java Tutorial »
    Java Langauge »
      Java Operator
Java Arithmetic Operators
Java Compound Assignment Operators
Java Increment and Decrement Operator
Java Logical Operators
Java Logical Operators Shortcut
Java Relational Operators
Java Bitwise Operators
Java Left Shift Operator
Java Right Shift Operator
Java Unsigned Right Shift
Java ternary operator