Binary/Decimal/Hexadecimal Converter / Discussion

Forum
» Forum 101 / Wiki Page Discussions
» Binary/Decimal/Hexadecimal Converter

This is the discussion related to the wiki page Binary/Decimal/Hexadecimal Converter.

You can download the file and open the .8xp program with software called TI Connect CE. This software will also allow you to transfer the program to your calculator with the direct USB cable.

Here is the source code anyway:

```
Lbl 0
For(K,1,16
0→L₁(K
End
For(K,1,4
0→L₂(K
End
DelVar ADelVar BDelVar CDelVar DDelVar EDelVar FDelVar GDelVar HDelVar KCrHome
Menu("Convert from…","…Binary",1,"…Decimal",2,"…Hexadecimal",3,"Exit",4
Lbl 4
ClrList L₁,L₂
Return
End
Lbl 1
Output(1,1," Please enter from RIGHT to LEFT.
Disp "","","
For(K,1,16
Input A
If A and A≠1
Then
17→K
End
A→L₁(K
End
DelVar A
For(K,1,16
If 1=L₁(K
Then
A+2^(K-1→A
End
End
Lbl 5
A→D
3→H
For(G,1,4
D/16^H→B
For(K,16,1,1
If B<K and B≥K-1
Then
K-1→C
C→L₂(G
End
End
D-C16^H→D
H-1→H
End
ClrHome
If A>65535
Then
Output(1,1,"I apologise, but the numbers you enter can't exceed decimal 65535. Your number was
Output(7,1,A
Pause
Goto 0
End
Output(2,1,"Binary
1→C
For(K,16,1,1
L₁(K)→B
Output(3,C,B
C+1→C
End
Output(4,1,"Decimal
Output(5,1,A
Output(6,1,"Hexadecimal
For(K,1,4
If 15=L₂(K
Then
Output(7,K,"F
End
If 14=L₂(K
Then
Output(7,K,"E
End
If 13=L₂(K
Then
Output(7,K,"D
End
If 12=L₂(K
Then
Output(7,K,"C
End
If 11=L₂(K
Then
Output(7,K,"B
End
If 10=L₂(K
Then
Output(7,K,"A
End
If 10>L₂(K
Then
L₂(K→B
Output(7,K,B
End
End
Pause
Goto 0
Lbl 2
ClrHome
Output(1,1," Please enter the number.
Disp "","
Input A
Lbl 6
A→B
For(K,15,0,1
If B-2^(K)≥0
Then
B-2^K→B
1→L₁(K+1
End
End
Goto 5
Lbl 3
ClrHome
Output(1,1,"Please enter the 4 digit number digit per digit.
10→A
11→B
12→C
13→D
14→E
15→F
Disp "","","
For(K,4,1,1
Input G
G→L₂(K
End
L₂(4)4096+L₂(3)256+L₂(2)16+L₂(1→A
Goto 6
```

I made a few trivial optimizations, but didn't change anything structurally.

There is no KcrHome command. Check to make sure your code is typed in correctly. :)

It reads "Delvar KClrHome" he forgot to put the 'l' in ClrHome. Hope that helps.

Eternity

Look, Even if this thread was active in April 2016, There is some things the creator needs to know.

There is still optimization that can be made, either by using the sub( command or by turning the:

```
:If 12=L2(K
:Then
:Output(7,K,C
:End
```

This can be optimized to *without* the End and Then commands.

I have heard, using Ans is quicker than the actual variable itself.

So,

```
:L2(K
:If Ans=12
:"C
:Output(7,K,Ans
```

/forum/t-1047756/binary-decimal-hexadecimal-converter#post-