Literals/Integer: Difference between revisions

From Rosetta Code
Content added Content deleted
(New page: {{task}}Some programming languages have ways of expressing integer literals in bases other than the normal base ten. Show how integer literals can be expressed in as many bases as your la...)
 
m (emphasis)
Line 3: Line 3:
Show how integer literals can be expressed in as many bases as your language allows.
Show how integer literals can be expressed in as many bases as your language allows.


Note: that 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|Python}}==
=={{header|Python}}==

Revision as of 23:04, 1 February 2009

Task
Literals/Integer
You are encouraged to solve this task according to the task description, using any language you may know.

Some programming languages have ways of expressing integer literals in bases other than the normal base ten.

Show how integer literals can be expressed in as many bases as your language allows.

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.

Python

<python>>>> # Bin(leading 0b), Oct(leading 0), Dec, Hex(leading 0x), in order: >>> 0b1011010111 == 01327 == 727 == 0x2d7 True >>> </python>