I am using python 2.7. I need to truncate a binary number from a x-bits to 8 bits (byte) i will write an example of what i would like to do to make it clear and also because stackexchange doesn't leave me write my question for some reason, example:
0b1010101010100101 -> 0b10100101
i tried this workaround: converting it to string and then cutting it as a sub-string, but i didn't manage to make it working
str_cs = str(bin(cs))
str_cs = str_cs[to_cut:]
but i am facing many problem to convert it back to a binary number... how would you truncate it?