tags:

views:

42

answers:

2

please tell me examples of [rotateLeft][1] method of Integer class in java

[1]: http://download-llnw.oracle.com/javase/6/docs/api/java/lang/Integer.html#rotateLeft(int, int)

A: 

Try java docs, they are your best friend (:

FallenAngel
thanks FallenAngel
Bipin Sahoo
+1  A: 

Rotation is an operation identical to shifting but that carries bits that goes out of the integer by placing them on the opposite side.. it's done on 2-bit complement (since everything is anyway signed in java) but just to give you an example with a byte data type if you have:

01101010

and you rotate it left by 2 bits you will obtain

10101001

because higher two bits are carried to the other end while all the others are just shifted.

Jack