bit_manipulation.reverse_bits¶
Functions¶
|
return the bit string of an integer |
|
Take in an 32 bit integer, reverse its bits, |
Module Contents¶
- bit_manipulation.reverse_bits.get_reverse_bit_string(number: int) str ¶
return the bit string of an integer
>>> get_reverse_bit_string(9) '10010000000000000000000000000000' >>> get_reverse_bit_string(43) '11010100000000000000000000000000' >>> get_reverse_bit_string(2873) '10011100110100000000000000000000' >>> get_reverse_bit_string("this is not a number") Traceback (most recent call last): ... TypeError: operation can not be conducted on a object of type str
- bit_manipulation.reverse_bits.reverse_bit(number: int) str ¶
Take in an 32 bit integer, reverse its bits, return a string of reverse bits
result of a reverse_bit and operation on the integer provided.
>>> reverse_bit(25) '00000000000000000000000000011001' >>> reverse_bit(37) '00000000000000000000000000100101' >>> reverse_bit(21) '00000000000000000000000000010101' >>> reverse_bit(58) '00000000000000000000000000111010' >>> reverse_bit(0) '00000000000000000000000000000000' >>> reverse_bit(256) '00000000000000000000000100000000' >>> reverse_bit(-1) Traceback (most recent call last): ... ValueError: the value of input must be positive
>>> reverse_bit(1.1) Traceback (most recent call last): ... TypeError: Input value must be a 'int' type
>>> reverse_bit("0") Traceback (most recent call last): ... TypeError: '<' not supported between instances of 'str' and 'int'