in reply to Factoring out common code in two methods of a class
further reading of the docs tells me that pack/unpack is not the way to do the bit-level twiddling. So I am looking into vec for the flag handling.
Look at vec by all means, but don't be surprised if you come back to unpack, or switch to masking and shifting.
The problem with vec is that it will only deal with powers-of-two numbers of bits. For example, there is no way to get at your 7-bit field directly using vec.
Of course, unpack has its problems too. Getting a 7-bit field back as 7 individual 0|1s isn't ideal. And you can get unintuative results if you attempt to unpack bits across byte-boundaries also.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Factoring out common code in two methods of a class
by jvector (Friar) on Aug 06, 2009 at 10:07 UTC |