Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -1,16 +1,15 @@
|
|||
/*REXX pgm to demonstrate handling an exception; catching is via a label*/
|
||||
do j=9 by -5 for 100
|
||||
/*REXX program demonstrates handling an exception; catching is via a label. */
|
||||
do j=9 by -5
|
||||
say 'square root of' j "is" sqrt(j)
|
||||
end /*j*/
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
|
||||
.sqrtNeg: say 'illegal SQRT argument (argument is negative):' x
|
||||
exit /*exit (terminate) this program. */
|
||||
|
||||
/*─────────────────────────────────────SQRT subroutine──────────────────*/
|
||||
sqrt: procedure; parse arg x; if x=0 then return 0; d=digits();numeric dig
|
||||
g=.sqrtGuess(); do j=0 while p>9; m.j=p; p=p%2+1; end
|
||||
do k=j+5 to 0 by -1; if m.k>11 then numeric digits m.k; g=.5*(g+x/g)
|
||||
numeric digits d; return g/1
|
||||
.sqrtGuess: if x<0 then signal .sqrtNeg; numeric form; m.=11; p=d+d%
|
||||
parse value format(x,2,1,,0) 'E0' with g 'E' _ .; return g*.5'E'_%
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*────────────────────────────────────────────────────────────────────────────*/
|
||||
sqrt: procedure; parse arg x; if x=0 then return 0; d=digits(); m.=9
|
||||
numeric digits 9; numeric form; h=d+6; if x<0 then signal .sqrtNeg
|
||||
parse value format(x,2,1,,0) 'E0' with g 'E' _ .; g=g*.5'e'_%2
|
||||
do j=0 while h>9; m.j=h; h=h%2+1; end /*j*/
|
||||
do k=j+5 to 0 by -1; numeric digits m.k; g=(g+x/g)*.5; end /*k*/
|
||||
numeric digits d; return (g/1) /*make complex if X < 0.*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue