Android Bit Check checkBitIsSet(byte bite, int offset)

Here you can find the source of checkBitIsSet(byte bite, int offset)

Description

Returns true if the specified offset bit is set to 1.

Parameter

Parameter Description
bite byte within which lies the bit to check.
offset the bit to check within the byte.

Return

true if bit is set to 1.

Declaration

public static boolean checkBitIsSet(byte bite, int offset) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from w  w w  . ja va  2  s  .c o m
     * Returns true if the specified offset bit is set to 1.
     * The offset should not be greater than 7.
     *
     * @param bite   byte within which lies the bit to check.
     * @param offset the bit to check within the byte.
     * @return true if bit is set to 1.
     */
    public static boolean checkBitIsSet(byte bite, int offset) {
        if (offset > 7 || offset < 0) {
            throw new IllegalArgumentException(
                    "Offset must be between 0 and 7!");
        }
        return (bite & (1 << offset)) != 0;
    }
}

Related

  1. checkBit(byte[] src, int index)
  2. checkBit(byte[] src, int index, boolean isLH)
  3. isBitSet(byte[] arr, int bit)