2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,9 +1,15 @@
|
|||
Some programming languages have ways of expressing integer literals in bases other than the normal base ten.
|
||||
|
||||
|
||||
;Task:
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
Also show any other ways of expressing literals, e.g. for different types of integers.
|
||||
|
||||
See also [[Literals/Floating point]].
|
||||
|
||||
;Related task:
|
||||
* [[Literals/Floating point]]
|
||||
<br><br>
|
||||
|
|
|
|||
2
Task/Literals-Integer/COBOL/literals-integer-1.cobol
Normal file
2
Task/Literals-Integer/COBOL/literals-integer-1.cobol
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
display B#10 ", " O#01234567 ", " -0123456789 ", "
|
||||
H#0123456789ABCDEF ", " X#0123456789ABCDEF ", " 1;2;3;4
|
||||
2
Task/Literals-Integer/COBOL/literals-integer-2.cobol
Normal file
2
Task/Literals-Integer/COBOL/literals-integer-2.cobol
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
if 1234 = 1,2,3,4 then display "Decimal point is not comma" end-if
|
||||
if 1234 = 1;2;3;4 then display "literals are equal, semi-colons ignored" end-if
|
||||
2
Task/Literals-Integer/Elena/literals-integer.elena
Normal file
2
Task/Literals-Integer/Elena/literals-integer.elena
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#var n := 1234. // decimal number
|
||||
#var x := 1234h. // hexadecimal number
|
||||
4
Task/Literals-Integer/Pascal/literals-integer.pascal
Normal file
4
Task/Literals-Integer/Pascal/literals-integer.pascal
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
const
|
||||
INT_VALUE = 15;
|
||||
OCTAL_VALUE = &017;
|
||||
BINARY_VALUE = %1111;
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
thing = 37
|
||||
thing = '37' /*this is exactly the same as above. */
|
||||
thing = "37" /*this is exactly the same as above also. */
|
||||
thing = '25'x /*this as well, expressed in hexadecimal. */
|
||||
thing = '00100101'b /*this too, expressed as binary. */
|
||||
|
||||
say 'base 10=' thing
|
||||
say 'base 2=' x2b(d2x(thing))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue