android - Converting sections of byte arrays to integer values -


i making android application accepts bluetooth measurement device. way data packaged in 4 bytes. need 2 values out of these bytes.

first value made of: 6bit , 7bit of first byte , bit 0 bit 6 of byte 2

second values simpler , consists of full 3rd byte.

what way access these bit values, combine them , convert them integer values? right i'm trying convert byte array bitset, , access individual bits create new bytes converted integer.

thanks, , please ask if not being clear enough.

im not sure if understood format correctly. bitmask correspond first value?

0xc07f0000 

that bits 16-22,30,31 (zero based indexing used here, i.e. bit 31 last bit).

another thing, value expected signed or unsigned?

anyway, if way assume can convert bitmasks:

unsigned int val = 0xdeadbeef;  unsigned int mask1 = 0xc0000000; unsigned int mask2 = 0x007f0000;  unsigned int yourvalue = (val&mask1)>>23 | (val&mask2)>>16; 

do in same way other values. define bitmask , shift right. done.

cheers


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -