langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,48 @@
/* NetRexx */
options replace format comments java crossref symbols nobinary
numeric digits 40 -- make lots of space for big numbers
numeric form scientific -- set output form for exponential notation
say 'Sample using objects of type "Rexx" (default):'
fv = 1.5; say '1.5'.right(20) '==' normalize(fv).right(20) -- 1.5
fv = -1.5; say '-1.5'.right(20) '==' normalize(fv).right(20) -- -1.5
fv = 15e-1; say '15e-1'.right(20) '==' normalize(fv).right(20) -- 1.5
fv = 3e-12; say '3e-12'.right(20) '==' normalize(fv).right(20) -- 3E-12
fv = 3e+12; say '3e+12'.right(20) '==' normalize(fv).right(20) -- 3000000000000
fv = 17.3E-12; say '17.3E-12'.right(20) '==' normalize(fv).right(20) -- 1.73E-11
fv = 17.3E+12; say '17.3E+12'.right(20) '==' normalize(fv).right(20) -- 17300000000000
fv = 17.3E+40; say '17.3E+40'.right(20) '==' normalize(fv).right(20) -- 1.73E+41
fv = 0.033e+9; say '0.033e+9'.right(20) '==' normalize(fv).right(20) -- 33000000
fv = 0.033e-9; say '0.033e-9'.right(20) '==' normalize(fv).right(20) -- 3.3E-11
say
say 'Sample using primitive type "float":'
ff = float
ff = float 15e-1; say '15e-1'.right(20) '==' normalize(ff).right(20) -- 1.5
ff = float 17.3E-12; say '17.3E-12'.right(20) '==' normalize(ff).right(20) -- 1.73E-11
ff = float 17.3E+12; say '17.3E+12'.right(20) '==' normalize(ff).right(20) -- 17300000000000
ff = float 0.033E+9; say '0.033E+9'.right(20) '==' normalize(ff).right(20) -- 33000000
ff = float 0.033E-9; say '0.033E-9'.right(20) '==' normalize(ff).right(20) -- 3.3E-11
say
say 'Sample using primitive type "double":'
fd = double
fd = 15e-1; say '15e-1'.right(20) '==' normalize(fd).right(20) -- 1.5
fd = 17.3E-12; say '17.3E-12'.right(20) '==' normalize(fd).right(20) -- 1.73E-11
fd = 17.3E+12; say '17.3E+12'.right(20) '==' normalize(fd).right(20) -- 17300000000000
fd = 17.3E+40; say '17.3E+40'.right(20) '==' normalize(fd).right(20) -- 1.73E+41
fd = 0.033E+9; say '0.033E+9'.right(20) '==' normalize(fd).right(20) -- 33000000
fd = 0.033E-9; say '0.033E-9'.right(20) '==' normalize(fd).right(20) -- 3.3E-11
say
return
/**
* Convert input to a Rexx object and add zero to the value which forces NetRexx to change its internal representation
*
* @param fv a Rexx object containing the floating point value
* @return a Rexx object which allows NetRexx string manipulation methods to act on it
*/
method normalize(fv) private constant
return fv + 0

View file

@ -0,0 +1,6 @@
0.5
1.0
1. (* it is not possible to write only "1" because OCaml is strongly typed,
and this would be interpreted as an integer *)
1e-10
3.14159_26535_89793

View file

@ -0,0 +1,3 @@
3 + .14159
3.14159
314.159E-2

View file

@ -0,0 +1,10 @@
1.2345e-4 decimal floating-point
7e5 decimal floating-point
1.234_567_89e0 decimal floating-point.
1.0s0 decimal floating-point (single precision)
1.0d0 decimal floating-point (double precision)
1.34q0 decimal floating-point (quadruple/extended precision)
111.0101e7b binary floating-point equals 111.0101 * 2**7
or 7.3125 * 2**7
1e5b binary floating-point equals 1 * 2**5

View file

@ -0,0 +1,4 @@
6.02e23 # standard E notation
:10<6.02 * 10 ** 23> # radix notation
:5<11.002 * 10 ** 23> # exponent is still decimal
:5<11.002*:5<20>**:5<43>> # all in base 5

View file

@ -0,0 +1,3 @@
3.14159265358979
1.0E-12
0.1234

View file

@ -0,0 +1,5 @@
0.
.1
1e3
123.456E-300
-123_456_789e+123