Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python bytes

def bit_length(self):
    s = bin(self)       # binary representation:  bin(-37) --> '-0b100101'
    s = s.lstrip('-0b') # remove leading zeros and minus sign
    return len(s)       # len('100101') --> 6
Source by docs.python.org #
 
PREVIOUS NEXT
Tagged: #Python #bytes
ADD COMMENT
Topic
Name
9+1 =