anybody know an easy way to encode a base 10 number into base 26?
Basically, I want to make a decimal number into the English alphabet:
A-Z. I was hoping there was a simpler way than:

i=input_number
output=""
alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
do while i>0
   j=i//26
   output=substr(alphabet,j+1,1)||output
   i=i%26
end
output="A"||output
output=strip(output,"L","A") /* strip leading "A"s */
if 0 = length(output) then output="A"

-- 
John McKown
Maranatha! <><

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to