| 1 | initial version |
If you want to make B an integer, as in your previous question, you can first try:
sage: ZZ(str(B))
262145
which looks retty weird. Thi is due to the fact that the number:
sage: str(B)
'01000001'
starts with a 0, indicating that it should undertand the representation to be in octal, while you want it in binary. Fortunately, you can specify the base in the conversion:
sage: b = ZZ(str(B), base=2) ; b 65 sage: b.parent() Integer Ring
| 2 | No.2 Revision |
If you want to make B an integer, as in your previous question, you can first try:
sage: ZZ(str(B))
262145
which looks retty pretty weird. Thi This is due to the fact that the number:
sage: str(B)
'01000001'
starts with a 0, indicating that it should undertand the representation to be in octal, while you want it in binary. Fortunately, you can specify the base in the conversion:
sage: b = ZZ(str(B), base=2) ; b 65 sage: b.parent() Integer Ring
| 3 | No.3 Revision |
If you want to make B an integer, as in your previous question, you can first try:
sage: ZZ(str(B))
262145
which looks pretty weird. This is due to the fact that the number:
sage: str(B)
'01000001'
starts with a 0, indicating that it should undertand the representation to be in octal, while you want it in binary. Fortunately, you can specify the base in the conversion:
sage: b = ZZ(str(B), base=2) ; b
65
sage: b.parent()
Integer | 4 | No.4 Revision |
If Let me just add a warning: if you want to make B an integer, as in your previous question, you can first try:
sage: ZZ(str(B))
262145
which looks pretty weird. This is due to the fact that the number:
sage: str(B)
'01000001'
starts with a 0, indicating that it should undertand the representation to be in octal, while you want it in binary. Fortunately, you can specify the base in the conversion:
sage: b = ZZ(str(B), base=2) ; b
65
sage: b.parent()
Integer Ring
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.