# RADCON # # Radix conversion procedures # # Ralph E. Griswold # # Last modified 5/29/83 # procedure exbase10(i,j) static digits local s, d, sign initial digits := "0123456789" || &lcase if i = 0 then return 0 if i < 0 then { sign := "-" i := -i } else sign := "" s := "" while i > 0 do { d := i % j if d > 9 then d := digits[d + 1] s := d || s i /:= j } return sign || s end procedure inbase10(s,i) if s[1] == "-" then return "-" || integer(i || "r" || s[2:0]) else return integer(i || "r" || s) end procedure radcon(s,i,j) return exbase10(inbase10(s,i),j) end