kutsurak / python-bitstring

Automatically exported from code.google.com/p/python-bitstring
0 stars 0 forks source link

Allow uint to be created without explicit length #99

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
So length defaults to i.bit_length():

    >>> s = Bits(uint=44)
    >>> s.len
    6

Can also be done for uintle, uintbe, uintne (rounding up to whole byte).

Not sure it makes sense for int etc., although bit_length() does work for 
negative integers, so it might be fine.

Note that (0).bit_length() == 0, which is something to think about - should 
zero need at least one bit or should we let it be an empty bitstring?

Original issue reported on code.google.com by dr.scott...@gmail.com on 24 Aug 2010 at 10:53

GoogleCodeExporter commented 9 years ago
On reflection I don't like the lack of an explicit length and don't think this 
change would be very useful. Better just to say bin(x) for most use cases...

Original comment by dr.scott...@gmail.com on 18 Jun 2011 at 6:28