Integer: rotateLeft(int i, int distance) : Integer « java.lang « Java by API






Integer: rotateLeft(int i, int distance)

 
import java.io.IOException;

public class MainClass {
  public static void main(String args[]) throws IOException {
    int n = 170; // 10101010

    System.out.println("Value in binary: 10101010");

    System.out.println("Number of one bits: " + Integer.bitCount(n));

    System.out.println("Highest one bit: " + Integer.highestOneBit(n));

    System.out.println("Lowest one bit: " + Integer.lowestOneBit(n));

    System.out.println("Number of leading zeros : " + Integer.numberOfLeadingZeros(n));

    System.out.println("Number of trailing zeros : " + Integer.numberOfTrailingZeros(n));

    System.out.println("\nBeginning with the value 1, " + "rotate left 16 times.");
    n = 1;
    for (int i = 0; i < 16; i++) {
      n = Integer.rotateLeft(n, 1);
      System.out.println(n);
    }

  }
}
           
         
  








Related examples in the same category

1.Integer.MAX_VALUE
2.Integer: MIN_VALUE
3.Integer: Integer.SIZE
4.Integer: bitCount(int i)
5.Integer: equals(Object obj)
6.Integer: highestOneBit(int i)
7.Integer: intValue()
8.Integer: lowestOneBit(int i)
9.Integer: numberOfLeadingZeros(int i)
10.Integer: numberOfTrailingZeros(int i)
11.Integer: reverseBytes(int i)
12.Integer: signum(int i)
13.Integer: toBinaryString(int intValue)
14.Integer: toHexString(int intValue)
15.Integer: toOctalString(int intValue)
16.Integer: parseInt(String stringValue)
17.Integer: valueOf(String stringValue)