# Java operators

samar
Java operators
Posted in : Java Interview Questions
What is the difference between the >> and >>> operators?

October 26, 2010 at 1:00 PM

Hi,

">>" is a signed right shift, while ">>>" is an unsigned right shift. What this means is that if you use a signed shift on a negative number, the result will still be negative. Signed right shifting by one is equivalent to dividing by two, even if the number is negative.

Unsigned shifting, on the other hand, ignores the sign of the number, and unsigned right shifting a negative number will result in a positive number -- which is why you generally shouldn't use the unsigned shift unless you are considering your number as unsigned.

The reason for the difference is that bytes, shorts, ints, and longs are all stored in two's-complement form (i.e. as signed numbers). This means, among other things, that the most significant bit is the sign bit, so that if the sign bit is 0 the number is positive, and if the sign bit is 1 the number is negative. If you want to divide a signed number by two by shifting it right, you have to retain the sign bit.

Another way of thinking about the difference between the operators is that the signed shift fills from the left with the sign bit (0 or 1), and the unsigned shift zero-fills from the left.

Thanks.

Java operators
Java operators  What is the difference between the >> and >>> operators
Java operators
Java operators  What is the % operator
Java Operators List
Java Operators List  What are the Java operators, please explain and share the Java operator list.   Java Operators List Any Java beginner can easily get confused with the types of Java operators and it can also
Operators in java 7
This tutorial describes the concept of operators in java 7
Operators In Java
Operators In Java In this section we will read about operators in Java. We will illustrate the use of operators in Java using a simple example. Java provides various operators to manipulate the operations in Java. Operators
java operators - Java Beginners
java operators  Hello...........Can we perform addition of two numbers without using any arithmatic operator?  Hi Friend, Yes, you can use BigInteger class to add, subtract,multiply,divide the numbers: import
operators
operators  Create a simple java program that adds, subtracts, divides and multiplies any two numbers that are entered by a user
Arithmetic Operators in java 7
In this section you will learn about the Arithmetic operators. This is one type of operators
Unary Operators in java 7
In this section you will learn about the Unary operators. This is one type of operators
Bitwise Operators in java 7
In this section you will learn about the Bitwise Operators. This is one type of operators
Other Operators in java 7
Other Operators in java 7 In this section you will learn about the Other Operators. This is one type of operators. Conditional Operator (? :): This is also called ternary operator. It contains three operand and two operators
Relational Operators in java 7
Relational Operators in java 7 In this section you will learn about the Equality and Relational operators. This is one type of operators. Equality and Relational Operators : Equality operator checks for equality of operands
Assignment Operators in java 7
Assignment Operators in java 7 In this section you will learn about the Assignment Operators. This is one type of operators. Assignment Operators : This operator is used whenever you need to assign some value to your variables. You
Operators
Operators       Operators are symbols that performs some operations on one or more then one operands. Once we declare and initialize variables, we can use operators to perform
Operators
Operators       Operators are symbols that performs some operations on one or more then one operands. Once we declare and initialize variables, we can use operators to perform
ciruit operators.
ciruit operators.  Explain the benefit of short ciruit operators
bitwise operators
bitwise operators  Write short note on bitwise operators of Java.   Please visit the following links: http://www.roseindia.net/java/java-tips/data/expressions/slides-bitops.shtml http://www.roseindia.net/java/java
difference between == and === operators?
difference between == and === operators?  Is (====) operator available in java or not? difference between
The Unary Operators
The Unary Operators in Java   ... operator. In java we have been provided the unary operators so we should know how... use of the unary  operators in java. First all of, we have to define
Operators
Operators       Operators are symbols that performs some operations on one or more than one operands. Once we declare and initialize variables, we can use operators to perform
Operators
Operators       Operators are symbols that performs some operations on one or more then one operands. Once we declare and initialize variables, we can use operators to perform
Operators and Expressions
to perform certain tasks like assigning a value, adding the numbers etc. Java operators... Operators and Expressions       Operators: Operators are such symbols that perform some
boolean operators in JavaScript
boolean operators in JavaScript  What boolean operators does JavaScript support
logical operators in objective c
logical operators in objective c  logical operators in objective c
SQL AND Operators
SQL AND Operators       The AND operator displays records if both conditions are true. 1st Condition 2nd Condition Result false
SQL OR Operators
SQL OR Operators       The OR operator displays records if any of the conditions is true. 1st Condition 2nd Condition Result false
bitwise operators
://www.roseindia.net/java/master-java/java-bitwise-or.shtml
What is the difference between the >> and >>> operators?
What is the difference between the >> and >>> operators?   hi, What is the difference between the >> and >>> operators? Thanks
The Arithmetic Operators
Java Example Using Arithmetic Operators       In this section we will learn how to calculate arithmetic operation. The java programming tutorial provide operators