Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * readBit
- * Determine if n bit is set.
- * bit is 0 based
- * @param value: the integer to read the bit from
- * @param bit: the bit to read, 0 based
- * @return true if bit is set; false if not set
- */
- public static boolean readBit(int value, int bit) {
- int posVal = (int)Math.pow(2, (double)bit);
- if ((value & posVal) == posVal) {
- return true;
- } else {
- return false;
- }
- } // end readBit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement