Working with bitarray

jglobe

Member
Joined
Aug 27, 2005
Messages
12
Programming Experience
1-3
Hi all,

I am a novice when working with binary data and wondered if some of you experts could help.

I have a byte array of which contain integers. The 8th bit of the first byte is a control bit which tells me if the integer continues into the next byte and the 7th bit is a sign bit. Bits 1 through 6 will be an integer. If the control bit is 1 then the integer continues to the next byte and in the next byte bits 1-7 will be added to the integer in the first byte.

Ex.
00000010 10001110
Byte 2 Byte 1

Byte2 = 128 + Byte1 = 142 -- Total = 270

Anyway to cut to the chase I am trying to figure out how to read this information.

Sorry if this sounds cryptic but as I said I am a newbie.

Thanks
 
I guess u need this

I couldn't get your question fully but i think u need this

Store the two bytes in two different arrays or (1 large array for both) using

modulas---divide by 2 method

Then to read it..traverse the array in reverse direction multiplying each bit value

with incrementing power of 2 (i.e. 2^0 for LSB...2^1 for 2 bit.......till 2^15 for

MSB) and then adding all of them to get the result:p
 
Back
Top