Java Array Shift shiftRightN(int[] block, int n)

Here you can find the source of shiftRightN(int[] block, int n)

Description

shift Right N

License

Open Source License

Declaration

static void shiftRightN(int[] block, int n) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    static void shiftRightN(int[] block, int n) {
        int i = 0;
        int bits = 0;
        for (;;) {
            int b = block[i];
            block[i] = (b >>> n) | bits;
            if (++i == 4) {
                break;
            }//from   w  w w  . jav  a 2 s. c o  m
            bits = b << (32 - n);
        }
    }

    static void shiftRightN(int[] block, int n, int[] output) {
        int i = 0;
        int bits = 0;
        for (;;) {
            int b = block[i];
            output[i] = (b >>> n) | bits;
            if (++i == 4) {
                break;
            }
            bits = b << (32 - n);
        }
    }
}

Related

  1. shiftRight(int[] result, int[] vec, int shift)
  2. shiftRight(int[] x)
  3. shiftRight(Object[] array, final int amount)
  4. shiftRight(T[] array)
  5. shiftRight2(T[] array, int to)
  6. shiftRightN(int[] block, int n)
  7. shiftRightN(int[] x, int n)
  8. shiftRightState(int[] state)
  9. shiftStringArray(String[] input)