%externalroutine Decimal %alias "3L___decimal"(%integer N, %integername Places, Digits, Vec) {The algorithm gets round the asymmetry of 2s complement by keeping} {N negative} %integer P, Sign, D, X Vec = Vec+15 {determine the sign} Sign = '-' %if N >= 0 %start N = -N Sign = ' ' Sign = 0 %if Places <= 0 %finish {Convert PLACES into the actual minimum number of characters to be generated} {including any sign} %if Places <= 0 %then Places = -Places %else Places = Places+1 {split up the number, leaving P as the number of digits} P = Vec %cycle {remember, N is negative} {avoid one division each time} X = N//10 D = N - X*10 {D = Rem(N, 10)} N = X {N = N//10} Vec = Vec-1; Byte(Vec) = '0'-D %repeat %until N = 0 %if Sign # 0 %start Vec = Vec-1; Byte(Vec) = Sign %finish Digits = P-Vec %end