pack a three byte int

John Machin sjmachin at lexicon.net
Thu Nov 9 20:27:37 EST 2006


p.lavarre at ieee.org wrote:


>
> Pack '<IH' doesn't match how the code that I'm refactoring thinks about
> these things.
>
> The people who wrote this stuff forty years ago were thinking of bit
> fields - here bit lengths of 8 then 3 then 21 then 8 then 8 bits -
> cheating only when the bit boundaries happened to hit byte boundaries.
>
> Yes, as you describe in this example, I could cheat when the boundaries
> happen to hit H or I boundaries as well, but then I'm still left coping
> with the cases where the fields split on byte boundaries that are not H
> or I boundaries, such as the example:
>
> Am I helping?

Yes, you have *finally* said unambiguously what your problem really is
-- field lengths not a multiple of 8 bits. I suggest that you start a
new thread, write it out logically and ask for assistance. You should
get some sensible answers. I will apologise in advance for not
participating; I'm exhausted.

Cheers,
John




More information about the Python-list mailing list