1 | initial version |
I am not completely sure about your question (please provide more details if i do not understand correctly), but you can transform the string '1000'
into the list of its letters as follows:
sage: list(a.binary())
['1', '0', '0', '0']
Note however that each entry is a string, not an integer. If you want a list of integers, you can transform each letter into an element of ZZ
:
sage: [ZZ(i) for i in a.binary()]
[1, 0, 0, 0]
2 | No.2 Revision |
I am not completely sure about your question (please provide more details if i do not understand correctly), but you can transform the string '1000'
into the list of its letters as follows:
sage: list(a.binary())
['1', '0', '0', '0']
Note however that each entry is a string, not an integer. If you want a list of integers, you can transform each letter into an element of ZZ
:
sage: [ZZ(i) for i in a.binary()]
[1, 0, 0, 0]
The bits
and digits
methods can give these bits (or "binary digits") directly as integers,
ordered the other way around:
sage: a.bits()
[0, 0, 0, 1]
sage: a.digits(base=2)
[0, 0, 0, 1]