Literals/Integer: Difference between revisions
Content deleted Content added
m →{{header|Python}}: 0X |
C / fix python to lang python (right?!) |
||
Line 4: | Line 4: | ||
Note: this should '''not''' involve the calling of any functions/methods but should be interpreted by the compiler or interpreter as an integer written to a given base. |
Note: this should '''not''' involve the calling of any functions/methods but should be interpreted by the compiler or interpreter as an integer written to a given base. |
||
=={{header|C}}== |
|||
Leading 0 means octal, 0x or 0X means hexadecimal. Otherwise, it is just decimal. |
|||
<lang c>#include <stdio.h> |
|||
int main() |
|||
{ |
|||
printf("%s\n", |
|||
( (727 == 0x2d7) && |
|||
(727 == 01327) ) ? "true" : "false"); |
|||
}</lang> |
|||
C has no way of specifying integers in binary (if there's something like <tt>0b...</tt>, it is not |
|||
standard) |
|||
=={{header|Python}}== |
=={{header|Python}}== |
||
<python>>>> # Bin(leading 0b), Oct(leading 0), Dec, Hex(leading 0x or 0X), in order: |
<lang python>>>> # Bin(leading 0b), Oct(leading 0), Dec, Hex(leading 0x or 0X), in order: |
||
>>> 0b1011010111 == 01327 == 727 == 0x2d7 |
>>> 0b1011010111 == 01327 == 727 == 0x2d7 |
||
True |
True |
||
>>> |
>>> |
||
</ |
</lang> |