June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
4
Task/Literals-Integer/Factor/literals-integer-1.factor
Normal file
4
Task/Literals-Integer/Factor/literals-integer-1.factor
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
10 . ! decimal
|
||||
0b10 . ! binary
|
||||
-0o10 . ! octal
|
||||
0x10 . ! hexadecimal
|
||||
2
Task/Literals-Integer/Factor/literals-integer-2.factor
Normal file
2
Task/Literals-Integer/Factor/literals-integer-2.factor
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
1,234,567 .
|
||||
1,23,4,567 .
|
||||
4
Task/Literals-Integer/HolyC/literals-integer-1.holyc
Normal file
4
Task/Literals-Integer/HolyC/literals-integer-1.holyc
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
U8 i; // 8 bit integer
|
||||
U16 i; // 16 bit integer
|
||||
U32 i; // 32 bit integer
|
||||
U64 i; // 64 bit integer
|
||||
2
Task/Literals-Integer/HolyC/literals-integer-2.holyc
Normal file
2
Task/Literals-Integer/HolyC/literals-integer-2.holyc
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
U16 i = 727; // decimal
|
||||
U16 i = 0x2d7; // hexadecimal
|
||||
18
Task/Literals-Integer/Limbo/literals-integer.limbo
Normal file
18
Task/Literals-Integer/Limbo/literals-integer.limbo
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
implement Command;
|
||||
|
||||
include "sys.m";
|
||||
sys: Sys;
|
||||
|
||||
include "draw.m";
|
||||
|
||||
include "sh.m";
|
||||
|
||||
init(nil: ref Draw->Context, nil: list of string)
|
||||
{
|
||||
sys = load Sys Sys->PATH;
|
||||
|
||||
sys->print("%d\n", 2r1111); # binary
|
||||
sys->print("%d\n", 8r17); # octal
|
||||
sys->print("%d\n", 15); # decimal
|
||||
sys->print("%d\n", 16rF); # hexadecimal
|
||||
}
|
||||
|
|
@ -1,10 +1,31 @@
|
|||
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. */
|
||||
/*REXX pgm displays an integer (expressed in the pgm as a literal) in different bases*/
|
||||
/*────────── expressing decimal numbers ──────────*/
|
||||
ddd = 123 /*a decimal number (expressed as a literal). */
|
||||
ddd = '123' /*this is exactly the same as above. */
|
||||
ddd = "123" /*this is exactly the same as above also. */
|
||||
/*────────── expressing hexadecimal numbers ──────*/
|
||||
hhh = '7b'x /*a value, expressed as a hexadecimal literal. */
|
||||
hhh = '7B'x /* (same as above) using a capital "B". */
|
||||
hhh = '7B'X /* (same as above) using a capital "X". */
|
||||
cow = 'dead beef'x /*another value, with a blank for the eyeballs.*/
|
||||
cow = 'de ad be ef'x /* (same as above) with blanks for the eyeballs.*/
|
||||
/*────────── expressing binary numbers ───────────*/
|
||||
bbb = '1111011'b /*a value, expressed as a binary literal. */
|
||||
bbb = '01111011'b /* (same as above) with a full 8 binary digits. */
|
||||
bbb = '0111 1011'b /* (same as above) with a blank for the eyeballs.*/
|
||||
|
||||
say 'base 10=' thing
|
||||
say 'base 2=' x2b(d2x(thing))
|
||||
say 'base 16=' d2x(thing)
|
||||
say 'base 256=' d2c(thing) /*the output shown is ASCII (or maybe EBCDIC).*/
|
||||
say ' base 10=' ddd
|
||||
say ' base 2=' x2b( d2x( ddd ) )
|
||||
say ' base 16=' d2x( ddd )
|
||||
say ' base 256=' d2c( ddd ) /*the output displayed is ASCII (or maybe EBCDIC).*/
|
||||
|
||||
thingy1= +123 /*╔══════════════════════════════════════════════╗*/
|
||||
thingy2= '+123' /*║ All of the THINGYs variables aren't strictly ║*/
|
||||
thingy3= ' 123' /*║ (exactly) equal to the DDD variable, but ║*/
|
||||
thingy4= 123. /*║ they do compare numerically equal. When ║*/
|
||||
thingy5= 12.3e+1 /*║ compared numerically, numbers are rounded to ║*/
|
||||
thingy6= 1230e-1 /*║ the current setting of NUMERIC DIGITS. The ║*/
|
||||
thingy7= 1230E-0001 /*║ default for (decimal) NUMERIC DIGITS is 9 ║*/
|
||||
thingy8= ' + 123 ' /*╚══════════════════════════════════════════════╝*/
|
||||
|
||||
/*stick a fork in it, we're all done. */
|
||||
|
|
|
|||
|
|
@ -4,3 +4,4 @@
|
|||
0o10 // Octal
|
||||
1_000 // Underscores may appear anywhere in the numeric literal for clarity
|
||||
10_i32 // The type (in this case i32, a 32-bit signed integer) may also be appended.
|
||||
10i32 // With or without underscores
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue