Hex to Decimal + back calulator program

Discussion in 'Embedded Systems and Microcontrollers' started by codehunter447, May 30, 2009.

  1. codehunter447

    Thread Starter Member

    Sep 7, 2008
    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.
  2. beenthere

    Retired Moderator

    Apr 20, 2004
  3. codehunter447

    Thread Starter Member

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

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

    :Lbl 0
    Disp "Hex to Decimal Converter"

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

    :Goto 2

    :While B>=16


    :Lbl 3
    :If E=1
    :If E=2
    :If F=0
    :If F=1
    :If F=2
    :If F=3
    :If F=4
    :If F=5
    :If F=6
    :If F=7
    :If F=8
    :If F=9
    :If F=10
    :If F=11
    :If F=12
    :If F=13
    :If F=14
    :If F=15

    :If E=1
    :Goto 3

    :Output(3,8, "{Decimal}
    :Output(4,1,"Converts into:"
    :Disp Str1
    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.
  4. Mark44

    Well-Known Member

    Nov 26, 2007
    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.

    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.
    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.
    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!
  5. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    I know this is not for a TI-84, but there is a fast little freeware Windows one here;
    which does HEX-Decimal-Binary and back again.
    It handles numbers from 8bit to 32bit.
  6. codehunter447

    Thread Starter Member

    Sep 7, 2008
    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