01-27-2017, 07:34 PM
For input
A
B
C
A,B,C integers the programme returns A / B to base C.
eg For input
5
111
7
the programme returns
:7: { "." "°" 0 2 1 3 1 0 3 3 5 }
Similarly
123
77
2
:2: { 1 "." "°" 1 0 0 1 1 0 0 0 1 1 1 0 1 1 1 1 0 1 1 0 0 0 0 0 0 1 1 0 1 0 }
and
17
11
107
:107: { 1 "." "°" 58 38 97 29 19 48 68 9 77 87 }
and
27
6
37
37: { 4 "." "°" 18 }
"°" indicates the beginning of the recursive part of the decimal.
A
B
C
A,B,C integers the programme returns A / B to base C.
eg For input
5
111
7
the programme returns
:7: { "." "°" 0 2 1 3 1 0 3 3 5 }
Similarly
123
77
2
:2: { 1 "." "°" 1 0 0 1 1 0 0 0 1 1 1 0 1 1 1 1 0 1 1 0 0 0 0 0 0 1 1 0 1 0 }
and
17
11
107
:107: { 1 "." "°" 58 38 97 29 19 48 68 9 77 87 }
and
27
6
37
37: { 4 "." "°" 18 }
"°" indicates the beginning of the recursive part of the decimal.
Code:
::
CK3&Dispatch
# AAA
::
FPTR2 ^CK3Z
BINT3
NDUP
FPTR2 ^QMul
FPTR2 ^QMul
FPTR2 ^QIsZero?
case2drop
::
FPTR2 ^DupQIsZero?
?SEMI
SETIVLERR
;
Z0_
FPTR2 ^2LAMBIND
2DUP
FPTR2 ^ZDIVext
SWAP
2GETLAM
NULL{}
3UNROLL
::
BEGIN
OVER
FPTR2 ^QIsZero?
case
AGAIN
DUPUNROT
FPTR2 ^ZDIVext
4ROLLSWAP
>HCOMP
SWAPROT
AGAIN
;
RDROP
2DROP
"."
>TCOMP
4UNROLL
FPTR2 ^QIsZero?
::
case2DROP
NULL{}
DUP4UNROLL
3UNROLL
BEGIN
DUPUNROT
FPTR2 ^ZDIVext
5ROLL
ROT
>TCOMP
4UNROLL
2GETLAM
FPTR2 ^QMul
SWAPROT
1GETLAM
>TCOMP
UNROTOVER
1PUTLAM
OVER
4PICK
FPTR2 ^ListPos
DUP#0=
WHILE
DROP
REPEAT
4UNROLL3DROP
1GETLAM
FPTR2 ^QIsZero?
::
caseDROP
"°"
SWAP
FPTR2 ^INSERT{}N
;
CDRCOMP
&COMP
;
2GETLAM
ABND
DO>STR
>TAG
;
;