Hex to Decimal + back calulator program

Thread Starter

codehunter447

Joined Sep 7, 2008
12
I would like to know how i could code a calculator program on a TI-84 Plus calculator that can convert a value in decimal (up to 65536) into a hex value (up to FFFF), or take a hex value (up to FFFF) and directly convert it into decimal?

Also my calculator programs in BASIC.
 

Thread Starter

codehunter447

Joined Sep 7, 2008
12
Thanks for the help. So far this is what i have for my Hex to Decimal Program:

*NOTE: "->" represents the store arrow symbol.*

:"0123456789ABCDEF"->Str0
:Lbl 0
:ClrHome
Disp "Hex to Decimal Converter"

:Lbl 2
:ClrHome
:Disp "Input Hex:"
:Disp "Between 0-FFFF"
:Input B
:If B>65535 or B<0

:Goto 2
:round(B,0)->B
:B/16->C

:round(C,0)->D
:C/16->D
:D-1->D
:While B>=16
:B-16->B
:END

:1->E

:Lbl 3
:If E=1
:B->F
:If E=2
:D->F
:If F=0
:"0"->Str1
:If F=1
:"1"->Str1
:If F=2
:"2"->Str1
:If F=3
:"3"->Str1
:If F=4
:"4"->Str1
:If F=5
:"5"->Str1
:If F=6
:"6"->Str1
:If F=7
:"7"->Str1
:If F=8
:"8"->Str1
:If F=9
:"9"->Str1
:If F=10
:"A"->Str1
:If F=11
:"B"->Str1
:If F=12
:"C"->Str1
:If F=13
:"D"->Str1
:If F=14
:"E"->Str1
:If F=15
:"F"->Str1

:If E=1
:Then
:2->E
:Goto 3
:End

:Output(3,8, "{Decimal}
:Output(3,1,(D*16)+B
:Output(4,1,"Converts into:"
:Output(5,12,"{Hex}"
:Output(5,1,Str1
:pause
:Disp Str1
:End
---------------------------------------
So when i go to run it on on my calculator it starts up fine, but after i input my value. It does not show my output at all.
 

Mark44

Joined Nov 26, 2007
628
I don't know the TI-84 code syntax, but I understand code in a variety of languages pretty well, so I'll take a shot at this.

Thanks for the help. So far this is what i have for my Hex to Decimal Program:

*NOTE: "->" represents the store arrow symbol.*

:"0123456789ABCDEF"->Str0
:Lbl 0
:ClrHome
Disp "Hex to Decimal Converter"

:Lbl 2
:ClrHome
:Disp "Input Hex:"
:Disp "Between 0-FFFF"
:Input B
:If B>65535 or B<0

:Goto 2
:round(B,0)->B
:B/16->C

:round(C,0)->D
:C/16->D
:D-1->D
:While B>=16
:B-16->B
:END

:1->E
It looks to me like the following code just puts one hex digit into Str1. It seems to me that you have to build up the hex string one hex digit at a time, and to do that you need a loop of some kind.
:Lbl 3
:If E=1
:B->F
:If E=2
:D->F
:If F=0
:"0"->Str1
:If F=1
:"1"->Str1
:If F=2
:"2"->Str1
:If F=3
:"3"->Str1
:If F=4
:"4"->Str1
:If F=5
:"5"->Str1
:If F=6
:"6"->Str1
:If F=7
:"7"->Str1
:If F=8
:"8"->Str1
:If F=9
:"9"->Str1
:If F=10
:"A"->Str1
:If F=11
:"B"->Str1
:If F=12
:"C"->Str1
:If F=13
:"D"->Str1
:If F=14
:"E"->Str1
:If F=15
:"F"->Str1

:If E=1
:Then
:2->E
:Goto 3
:End
You're missing a quote in the next line. Also, it looks like all of your Output statements are missing a right parenthesis. I don't know the syntax of your TI-84 code, so possibly that's not an error. It sure looks weird to me, though.
:Output(3,8, "{Decimal}
:Output(3,1,(D*16)+B
:Output(4,1,"Converts into:"
:Output(5,12,"{Hex}"
:Output(5,1,Str1
:pause
:Disp Str1
:End
---------------------------------------
So when i go to run it on on my calculator it starts up fine, but after i input my value. It does not show my output at all.
Since you're not getting any output, and since you are programming in an environment without any debugging support, what you're going to need to do is to insert Output or Disp statements along the way. This is probably the oldest technique of debugging computer programs.

It would be useful to display a statement that says what you're expecting to get, and then display that variable. As you through your program, if what you're expecting to get is what is actualy displayed, good. At some point, though, you'll reach a point where you're expecting to get a certain value, and you'll get a different value or nothing at all, and then you can determine why that is happening.

This is a pretty simple program, so it shouldn't be to hard to debug it. Good luck and happy (bug) hunting!
 

Thread Starter

codehunter447

Joined Sep 7, 2008
12
Alright well i just wanted to thanks you guys for your help with my program but i was able to find one that works for converting Decimal to Binary and hex, or any other combination of the three. Also at the end it still shows you, your starting value and base, along with the answer.

But i do have more quick question is there anyway that i can make in a program where i can already have an equation and just have to enter in the certain values at the beginning of the program. For example i equation that i have to use a lot is for finding the time delay of a program.

With "A" being the variable that i want to be able to enter.

Its a two step equation as follows:
1. 65535 - A = B
2. B * 1.085 μ seconds = Final Answer
 
Top