Android Bit Check isBitSet(byte[] arr, int bit)

Here you can find the source of isBitSet(byte[] arr, int bit)

Description

is Bit Set

License

Open Source License

Declaration

public static boolean isBitSet(byte[] arr, int bit) 

Method Source Code

//package com.java2s;

public class Main {
    public static boolean isBitSet(byte[] arr, int bit) {
        int index = bit / 8; // Get the index of the array for the byte with this bit
        int bitPosition = bit % 8; // Position of this bit in a byte

        return (arr[index] >> bitPosition & 1) == 1;
    }//from   w  ww  . j  ava  2 s  .  com
}

Related

  1. checkBit(byte[] src, int index)
  2. checkBit(byte[] src, int index, boolean isLH)
  3. checkBitIsSet(byte bite, int offset)