Literals/Integer: Difference between revisions
Content deleted Content added
→{{header|Python}}: show transition to 3.0 from 2.5 |
|||
Line 134: | Line 134: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
{{works with|Python|3.0}} |
{{works with|Python|3.0}} |
||
Python 3.0 brought in the binary literal and uses 0o or 0O exclusively for octal. |
|||
⚫ | |||
<lang python>>>> # Bin(leading 0b or 0B), Oct(leading 0o or 0O), Dec, Hex(leading 0x or 0X), in order: |
<lang python>>>> # Bin(leading 0b or 0B), Oct(leading 0o or 0O), Dec, Hex(leading 0x or 0X), in order: |
||
>>> 0b1011010111 == 0o1327 == 727 == 0x2d7 |
>>> 0b1011010111 == 0o1327 == 727 == 0x2d7 |
||
True |
|||
>>> |
|||
</lang> |
|||
⚫ | |||
Python 2.6 has the binary and new octal formats of 3.0, as well as keeping the earlier leading 0 octal format of previous 2.X versions for compatability. |
|||
<lang python>>>> # Bin(leading 0b or 0B), Oct(leading 0o or 0O, or just 0), Dec, Hex(leading 0x or 0X), in order: |
|||
>>> 0b1011010111 == 0o1327 == 01327 == 727 == 0x2d7 |
|||
True |
True |
||
>>> |
>>> |