Ask Your Question

Revision history [back]

One can convert this "long" to a "Sage integer", and use the method "bits".

sage: a = 189866136719308462018271159242437168532L
sage: b = ZZ(a).bits()

How many bits do we have:

sage: len(b)
128

Show the first eight bits

sage: b[:8]
[0, 0, 1, 0, 1, 0, 0, 1]

and the last eight bits

sage: b[-8:]
[0, 1, 1, 1, 0, 0, 0, 1]