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

Popular posts from this blog

sql - Find last match with latest inserted name in table -

c# - XML serialize base class without knowing derived class -

ios - Invalid IPA: missing embedded provisioning profile. Are you sure this is an ad hoc? -