Re: Base Conversion


[Prev][Next][Index][Thread]

Re: Base Conversion



>   jwardell@aol.com (JWardell) writes:
>  Does anyone have or know of good bes conversion programs, for the 82, 83,
>  or 92? It would be great if it could do simple +/-/*// too. Thanks.
        [snip]
>                            -Josh Wardell
>  http://users.aol.com/jwardell/JWardell.html
>
>>>>
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\
----begin uue----
begin 664 basecnv.83p
M*BI423@S*BH:"@!"87-E($-O;G9E<G-I;VXZ(#(\/4)A<V4\/3,V````````
M``````````!A`PL`4@,%0D%314-.5@!2`U`#*C`Q,C,T-38W.#E!0D-$149'
M2$E*2TQ-3D]045)35%565UA96BH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