Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow uint to be created without explicit length #99

Closed
GoogleCodeExporter opened this issue Apr 11, 2015 · 1 comment
Closed

Allow uint to be created without explicit length #99

GoogleCodeExporter opened this issue Apr 11, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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

  • Changed state: WontFix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant