我有一个整数,如:
0x10000010
我想知道某个特定位是 1 还是 0。例如,类似:
int number = 0x10000010;
for (int i = 0; i < 8; i++) {
if (ith bit == 1) {
System.out.println("bit " + i + " is 1.");
} else {
System.out.println("bit " + i + " is 0.");
}
}
---- output ----
bit 0 is 1
bit 1 is 0
bit 2 is 0
bit 3 is 0
bit 4 is 0
bit 5 is 0
bit 6 is 1
bit 7 is 0
我忘了怎么做,这种操作叫什么,
谢谢