On Tue, 2 Aug 2011 17:25:38 -0500, Ward, Mike S wrote: >Ok how about something like this? > >/* REXX */ >input_number = 27 >XSTRING = D2C(input_number) >XTABLEI = '0102030405060708090A0B0C0D0E0F101112131415161718191A'x >XTABLEO = ABCDEFGHIJKLMNOPQRSTUVWXYZ >X = TRANSLATE(XSTRING,XTABLEO,XTABLEI) >say X
"Base 26" refers to a number system in which each digit position has 26 possible values, just as in base 16 (hexadecimal) there are 16 possible valued in each digit position. The value of a digit at the rightmost position is multiplied by 26**0 (1). The next position is multiplied by 26**1 (26), the third position by 26**2 (676), etc. If the digit values are represented by the English letters A through Z, with A having values from 0 to 25, respectively, the counting sequence from decimal 1 through 26 would be B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, BA. -- Tom Marchant > >-----Original Message----- >From: IBM Mainframe Discussion List [mailto:IBM-MAIN@bama.ua.edu] On >Behalf Of John McKown >Sent: Monday, August 01, 2011 4:22 AM >To: IBM-MAIN@bama.ua.edu >Subject: "base" arithmetic in REXX > >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" ---------------------------------------------------------------------- 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