java - Set bit values in Byte -
I need to set bits for some Bluetooth features listed under Java:
HeaderValue: BluetoothFeature, Tag ID: 0x10, length: 4 bytes, Possible values: bit 0 = A, bit1 = b, bit2 = c, bit3 = d, bit4 = e .... so many bits 31.
1 to set the seventh bit:
B = (byte) (b | (1 ; 6));
To set the sixth bit to zero:
b = (byte) (b & amp; nbsp; (1 & lt; <5 ));
(The bit position is 0-based, effectively, so the map "seventh bit" 1 = <1 instead of << Source:
Comments
Post a Comment