Skip to content

Commit

Permalink
Simplify FSQRT-NEWTON - #42
Browse files Browse the repository at this point in the history
  • Loading branch information
ikysil committed Sep 27, 2017
1 parent 9d8f991 commit 80dce31
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions lib/~ik/float-ieee-binary/f-sqrt.4th
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,12 @@
\G Calculate square root of r1 given the initial approximation r2 and number of iterations +n.
\G xt calculates next approximation with stack effect (F r1 r2 -- r3 ).
1 ?FPSTACK-OVERFLOW
>R
BEGIN
DUP 0>
?FPX0= INVERT \ stop iterations if approximation eq. zero
AND
WHILE
SWAP
0 ?DO
FOVER FSWAP
\DEBUG S" FSQRT-NEWTON-A1: " CR TYPE CR F.DUMP CR
R@ EXECUTE
\DEBUG S" FSQRT-NEWTON-A2: " CR TYPE CR F.DUMP CR
1-
REPEAT
DUP EXECUTE
LOOP
DROP
R> DROP
FNIP
\DEBUG S" FSQRT-NEWTON-B: " CR TYPE CR F.DUMP CR
;
Expand Down

0 comments on commit 80dce31

Please sign in to comment.