polymerist.genutils.bits
For bitwise operations and conversions to/from bitstrings
Functions
|
Convert an integer into a string of its bits, padded out to <num_bits> bits |
Module Contents
- polymerist.genutils.bits.int_to_bits(n: int, num_bits: int = 8, clamp: bool = False, as_list: bool = False) str | list[int][source]
Convert an integer into a string of its bits, padded out to <num_bits> bits If clamp=True and the binary representation of <n> has more than <num_bits> bits, then leading bits will be discarded If as_list=True, will return as list of 0/1 ints; otherwise, will return as string