Reverse and rotate the integer in binary format

ReturnMethodSummary
static intreverse(int i)Reversing the bits.
static intreverseBytes(int i)Reversing the bytes.
static introtateLeft(int i, int distance)Rotating the bits by distance.
static introtateRight(int i, int distance)Rotating the bits by distance.

public class Main {
  public static void main(String[] args) {

    System.out.println(Integer.reverse(10));

  }
}

The output:


1342177280

public class Main {
  public static void main(String[] args) {

    System.out.println(Integer.rotateLeft(10,2));

  }
}

The output:


40
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.