Convert a byte into a bit-flagged array
1
Output is a boolean array of the size 8 where true is for "1" and false for "0"
public static boolean[] convertToBits(byte b) {
boolean[] bits = new boolean[8];
for (int i = 0; i < bits.length; i++) {
bits[7 - i] = ((b & (1 << i)) != 0);
}
return bits;
}






There are currently no comments for this snippet.