Here you can find the source of checkBitIsSet(byte bite, int offset)
Parameter | Description |
---|---|
bite | byte within which lies the bit to check. |
offset | the bit to check within the byte. |
public static boolean checkBitIsSet(byte bite, int offset)
//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; } }