Java Array Shift shiftRight(byte[] block)

Here you can find the source of shiftRight(byte[] block)

Description

shift Right

License

Open Source License

Declaration

static void shiftRight(byte[] block) 

Method Source Code

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

public class Main {
    static void shiftRight(byte[] block) {
        int i = 0;
        int bit = 0;
        for (;;) {
            int b = block[i] & 0xff;
            block[i] = (byte) ((b >>> 1) | bit);
            if (++i == 16) {
                break;
            }/*  ww  w. j ava  2 s  .c  o m*/
            bit = (b & 1) << 7;
        }
    }

    static void shiftRight(byte[] block, byte[] output) {
        int i = 0;
        int bit = 0;
        for (;;) {
            int b = block[i] & 0xff;
            output[i] = (byte) ((b >>> 1) | bit);
            if (++i == 16) {
                break;
            }
            bit = (b & 1) << 7;
        }
    }

    static void shiftRight(int[] block) {
        int i = 0;
        int bit = 0;
        for (;;) {
            int b = block[i];
            block[i] = (b >>> 1) | bit;
            if (++i == 4) {
                break;
            }
            bit = b << 31;
        }
    }

    static void shiftRight(int[] block, int[] output) {
        int i = 0;
        int bit = 0;
        for (;;) {
            int b = block[i];
            output[i] = (b >>> 1) | bit;
            if (++i == 4) {
                break;
            }
            bit = b << 31;
        }
    }
}

Related

  1. ShiftLeftOne(int[] arr)
  2. shiftNibbles(byte[] bytes)
  3. shiftOff(T[] a)
  4. shiftOffsets(int[] offsets, int changeOffset, int oldLength, int newLength)
  5. shiftOnRow(double[][] d, int q)
  6. shiftRight(byte[] x)
  7. shiftRight(int[] result, int[] vec, int shift)
  8. shiftRight(int[] x)
  9. shiftRight(Object[] array, final int amount)