- byte byData = 0x36;
- int n0, n1, n2, n3, n4, n5, n6, n7;
- n0 = (byData & 0x01) == 0x01 ? 1 : 0;
- n1 = (byData & 0x02) == 0x02 ? 1 : 0;
- n2 = (byData & 0x04) == 0x04 ? 1 : 0;
- n3 = (byData & 0x08) == 0x08 ? 1 : 0;
- n4 = (byData & 0x10) == 0x10 ? 1 : 0;
- n5 = (byData & 0x20) == 0x20 ? 1 : 0;
- n6 = (byData & 0x40) == 0x40 ? 1 : 0;
- n7 = (byData & 0x80) == 0x80 ? 1 : 0;
取出一个字节(byte)中的每一位(bit)
最新推荐文章于 2022-08-16 14:38:18 发布