I do some sort of calculation and in the end I have an int that needs at most 16 bits to represent. I want to pack it into a string in unsigned short int format. For example, if I have 1223, I want to store 0000010011000111.
I tried using:
n = pack('H', 1223)
When I tried to print in (in binary representation) I got:
11000111 100
But I want the leading zeros to also be encoded into n, how can I do it elegantly?