Creating a 16 bit section using BitVector32.CreateSection
I am working on a project where I need to write arrays of bits onto a network connection. The data to be written are 32 bit aligned, i.e. all data is a multiple of 32 bits. My first thinking was to use Bitvector32 to create 32 bit words and then create sections in these bitvectors to reference my data. I do have fields in my data that are 3 or 6 bits, so all data fields are not byte aligned.
BitVector32 on msdn:
http://msdn.microsoft.com/en-us/library/system.collections.specialized.bitvector开发者_开发知识库32.aspx
This all seems fine, but problem arise when I am to create a section of 16 bits (2 bytes).
The API has: CreateSection(Int16) where the argument is the largest number to be held by the section. Since I am supposed to pass a signed 16 bit int to this the largest numer I can pass is 0x7FFF. To represent this we will need... 15 bits. So, using the API, I cannot create a 16 bit section of a BitVector32.
Or can I?
精彩评论