Is there some way to get the actual bit representation, instead of the garbage ‘-0bx’? I need to actually be able to see the bits. Whether or not it comes out big/little endian doesn’t matter. This is for an assignment.
Does anyone know how to view the actual 2’s complement bit representation of an integer in python?
Is there some way to get the actual bit representation, instead of the garbage
Share
Because the number isn’t constrained to a bit range, there is no canonical “the bits” representation. The output would be
0b1,0b11111111,0b1111111111111111, etc. depending on which bit range you happened to intend.Would the following give what you want?
Note: This doesn’t pad with
0es to give a fixed length, as Ned’s suggestion does.