Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,51 @@
/*REXX program computes and displays various (integer) exponentiations. */
say center('digits='digits(), 79, "")
say 'iPow(17, 65) is:'
say iPow(17, 65)
say
say 'iPow(0, -3) is:'
say iPow(0, -3)
say
say 'iPow(8, 0) is:'
say iPow(8, 0)
say
numeric digits 12; say center('digits='digits(), 79, "")
say 'iPow(2, -10) is:'
say iPow(2, -10)
say
numeric digits 30; say center('digits='digits(), 79, "")
say 'iPow(-3.1415926535897932384626433, 3) is:'
say iPow(-3.1415926535897932384626433, 3)
say
numeric digits 60; say center('digits='digits(), 79, "")
say 'iPow(5, 70) is:'
say iPow(5, 70)
say
numeric digits 100; say center('digits='digits(), 79, "")
say 'iPow(17, 65) is:'
say iPow(17, 65)
say
numeric digits 1000; say center('digits='digits(), 79, "")
say 'iPow(2, 1000) is:'
say iPow(2, 1000)
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
errMsg: say; say '***error***'; say; say arg(1); say; say; exit 13
/*──────────────────────────────────────────────────────────────────────────────────────*/
iPow: procedure; parse arg x 1 _,p; #args= arg() /*_: is a copy of X. */
if #args<2 then call errMsg "not enough arguments specified"
if #args>2 then call errMsg "too many arguments specified"
if \datatype(x, 'N') then call errMsg "1st arg isn't numeric:" x
if \datatype(p, 'W') then call errMsg "2nd arg isn't an integer:" p
if p=0 then return 1 /*handle powers of zero. */
if x=0 | x=1 then return x /*handle special cases. */
do abs(p) - 1; _= _ * x; end /*perform exponentiation */
if p<0 then _= 1 / _ /*process its reciprocal.*/
return _

View file

@ -0,0 +1,24 @@
pp: Procedure
Parse Arg x,y
If x=0 & y<0 Then call errMsg x"**" y "is invalid"
yp=abs(y)
p.1=x
x.1=1
i=1
Do k=2 By 1 While i<=yp%2
i=2*i
kk=k-1
p.k=p.kk*p.kk
x.k=i
/* Say k i x.k p.k */
End
pp=1
Do i=k-1 To 1 By -1
If x.i<=yp Then Do
pp=pp*p.i
yp=yp-x.i
End
End
If y<0 Then
pp=1/pp
Return pp