Metropoli BBS
VIEWER: div.txt MODE: TEXT (ASCII)
a # 1 60 R ' c#a div b;q;t                                              '
a # a,[1]  '"multiprecision integer divide with remainder               '
a # a,[1]  ' $(2^=Rb#fix b)/l2                                          '
a # a,[1]  '"special code for speed if b is scalar                      '
a # a,[1]  ' $c#(2X(b#1Ub)=1Yrem#0,1Ya#fix a)R0                         '
a # a,[1]  'l1:c#c,q#D(t#10000000Brem,1Ya)%b                            '
a # a,[1]  ' rem#0,t_qXb                                                '
a # a,[1]  ' $(0<Ra#1Ua)/l1                                             '
a # a,[1]  ' $0,Rc#can c                                                '
a # a,[1]  'l2:rem#a#fix a                                              '
a # a,[1]  ' $(b&.=''''Rc#0 0)Ul4,0                                       '
a # a,[1]  'l3:q#canD(10000000B3Yrem)%10000000B2Yb                      '
a # a,[1]  ' c#c add q#(-1+(Rq)+(Rrem)_Rb)Yq                            '
a # a,[1]  ' rem#rem sub b mul q                                        '
a # a,[1]  'l4:$(X(Rrem)_Rb)Yl3,0                                       '
a # a,[1]  ' $l3X(|1U2Yrem)>|1U2Yb                                      '
a # a,[1]  ' $0                                                         '
a # a,[1]  '"div - multiprecision integer division                      '
a # a,[1]  '"from ''the apl handbook of techniques'' copyright 1978, ibm. '
a # a,[1]  '"-divide a by b, giving c, using multiprecision integer     '
a # a,[1]  '" arithmetic; a and b may be in any numeric format, c will  '
a # a,[1]  '" be mp integer.  see Gadd.                                 '
a # a,[1]  '"-uses: Gadd Gsub Gmul Gfix Gcan                            '
Lfx a
[ RETURN TO DIRECTORY ]