Tim Roberts wrote:
Monica Leko <[EMAIL PROTECTED]> wrote:
I have a specific format and I need binary representation.  Does
Python have some built-in function which will, for instance, represent
number 15 in exactly 10 bits?

For the record, I'd like to point out that even C cannot do this.  You need
to use shifting and masking to produce a stream of 8-bit bytes, or to
extract your values from a stream of 8-bit bytes.


Hmmmm, bitfields are exactly non-aligned bits in a structure and are part of ANSI C. Although C gives no guarantee of the ordering of fields within machine words ... so bitfieds are of limited use in portable programs unless they are 0-initialized.

IIRC, Huffman code uses arbitrary length bit strings and is the basis of many compression algorithms.




--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to