Literals/Integer

From Rosetta Code
Revision as of 23:03, 1 February 2009 by rosettacode>Paddy3118 (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...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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: 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.

Python

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