1.int(整型)占4个字节(Byte),32位(Bit)
例如:
int a = 82;
byte[] temp = BitConverter.GetBytes(a); //转为字节组,为4个。转16进制后为:0x52,0x00,0x00,0x00
只要a不超255,那么它其实永远只用到一个字节,后边3个都为0x00.
所以当a不超255时,我们可以 byte b= byte(a); 把a转成一个单字节进行求位操作。注意,如果超出255就会报错
int a=255;
byte d=(byte)a;
byte & 1= 0位
byte & 2= 1位
byte & 4= 2位
byte & 8= 3位
byte & 16=4位
byte & 32= 5位
byte & 64= 6位
byte & 128= 7位
byte & 1==0 !=0 //结果有0和非0,非0即为1