basecnv This TI-83 program converts numbers from one base to another using conventional ASCII string notation. ----begin documentation---- This program is loosely based on BASECONV for the TI-82 by Mikael Bonnier (mikaelb@df.lth.se). It makes use of the TI-83's string functions so that input and output appear in normal alphanumeric notation. The length is due to thorough validation of all input. To save time, strings are not used for base 10 input and output. When started, the program prompts for input and output bases, which are entered as decimal numbers no smaller than 2 and no larger than 36. It then prompts for N, the number to be converted. N is entered as a string of alphanumeric digits in the input base notation, so that if the input base is 16, digits 0 through 9 and A through F may be input. For base 36, all letters including Z can be used. If the input contains invalid digits, the first is flagged. When the input is valid, the output appears on the next line in the output base notation. Then, when ENTER is pressed, the program is ready to accept another input in the same base. To quit, enter 0 (which is the same in any base). The program cleans up after itself, deleting all variables used (I, J, N - R, Str1 - Str9) except: I, which contains the input base, O, which contains the output base, N, which contains the converted number (base 10) Str1, which contains the input (if not base 10), and Str2, which contains the output (if not base 10). Thus, after exiting the program, it is possible to store the converted number N in a different variable. For example, to store it as M, one would key in N\->\M. If, after converting M and N, the program is restarted with 10 as the input base, the number to be converted can be entered as an expression, like M+N, M-N, MN, or int(M/N). More complex expressions can be entered in the same way. This allows the results of calculations to be displayed in the output base. ----begin ASCII---- \start83\ \comment=Base Conversion: 2<=Base<=36 \name=BASECNV \file=BASECNV.TXT "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"\->\Str3 " INPUT BASE: "\->\Str4 "OUTPUT BASE: "\->\Str5 "PRESS ENTER"\->\Str6 "ERROR: "\->\Str7 "NON-INT"\->\Str8 0\->\P Lbl A ClrHome Disp "BASE CONVERSION" Disp "" If P=0 Then Input Str4,I Goto B Else Disp "" Output(3,1,Str4) Output(3,14,I) End If P=1 Then Input Str5,O Goto B Else Disp "" Output(4,1,Str5) Output(4,14,O) End Disp "N OR 0 TO QUIT:" If I=10 Then DelVar Str1 Input "",R If R=0 Goto Z If R<0 or R\!=\int(R) Then If R\!=\int(R) Output(7,1,Str7+Str8) If R<0 Output(7,1,Str7+"N < 0 ") Output(8,1,Str6) Pause Goto A End Else Input "",Str9 If Str9="0" Goto Z Str9\->\Str1 0\->\R For(J,1,length(Str1)) inString(Str3,sub(Str1,J,1))-1\->\Q If Q<0 or Q\>=\I Then Output(7,1,"INVALID DIGIT: ") Output(7,16,sub(Str1,J,1)) Output(8,1,Str6) Pause Goto A End IR+Q\->\R End End Output(5,1," ") R\->\N If O=10 Then DelVar Str2 Output(7,1,N) Else " "\->\Str2 For(J,1,int(round(ln(R)/ln(O),7))+1) sub(Str3,round(OfPart(R/O),0)+1,1)+Str2\->\Str2 int(R/O)\->\R End sub(Str2,1,length(Str2)-1)\->\Str2 Output(7,1,Str2) End Output(8,1,Str6) Pause Goto A Lbl B If P=0 I\->\O If O\>=\2 and O\<=\36 and O=int(O) Then P+1\->\P Else If O\!=\int(O) Output(5+P,1,Str7+Str8) If O<2 Output(5+P,1,Str7+"BASE < 2") If O>36 Output(5+P,1,Str7+"BASE > 36") Output(6+P,1,Str6) Pause End Goto A Lbl Z DelVar J DelVar P DelVar Q DelVar R DelVar Str3 DelVar Str4 DelVar Str5 DelVar Str6 DelVar Str7 DelVar Str8 DelVar Str9 ClrHome \stop83\ Harry Elam hbe@way.com