# itoc - convert integer int to char string in str include ratdef define(abs,iabs) integer function itoc(int, str, size) integer abs, mod integer i, int, intval, j, k, size character str(ARB) intval = abs(int) str(1) = EOS i = 1 repeat { # generate digits i = i + 1 str(i) = DIG0 + mod(intval,10) intval = intval / 10 } until (intval == 0 | i >= size) if (int < 0 & i < size) { # then sign i = i + 1 str(i) = MINUS } itoc = i - 1 for (j = 1; j < i; j = j + 1) { # then reverse k = str(i) str(i) = str(j) str(j) = k i = i - 1 } return end