Example usage for java.lang Integer rotateRight

List of usage examples for java.lang Integer rotateRight

Introduction

In this page you can find the example usage for java.lang Integer rotateRight.

Prototype

public static int rotateRight(int i, int distance) 

Source Link

Document

Returns the value obtained by rotating the two's complement binary representation of the specified int value right by the specified number of bits.

Usage

From source file:Main.java

public static void main(String args[]) {
    int n = 1;//from  w  w  w.  ja va2 s . c o  m
    for (int i = 0; i < 16; i++) {
        n = Integer.rotateRight(n, 1);
        System.out.println(n);
    }

}

From source file:Main.java

static void scaleHalf(IntBuffer in, int w, int h, IntBuffer out, int rotate) {
    for (int i = 0; i < w / 2; ++i) {
        for (int j = 0; j < h / 2; ++j) {
            int k = w * 2 * j + 2 * i;
            int pixel00 = in.get(k);
            int pixel01 = in.get(k + 1);
            int pixel10 = in.get(k + w);
            int pixel11 = in.get(k + w + 1);

            if (rotate != 0) {
                pixel00 = Integer.rotateLeft(pixel00, rotate);
                pixel01 = Integer.rotateLeft(pixel01, rotate);
                pixel10 = Integer.rotateLeft(pixel10, rotate);
                pixel11 = Integer.rotateLeft(pixel11, rotate);
            }//from  ww  w .  ja  va  2s  .c  o m

            int pixel = average4RGBA(pixel00, pixel01, pixel10, pixel11);

            if (rotate != 0) {
                pixel = Integer.rotateRight(pixel, rotate);
            }

            out.put(w / 2 * j + i, pixel);
        }
    }
}