Wednesday, February 20, 2013

TI-84+: Binary-Decimal Conversions

One of the missing features of the TI-82/83/84 family is the ability to convert between bases. Here are two programs in TI-Basic to help fill at least some of the gap.

It is very basic conversion, working only with positive integers up to 65,535 (16 ones as its binary representation).

Variables used:
N = number in decimal form
L1 = list representing the binary representation (1s and 0s)

The programs display the binary numbers as a solid number, rather by a list. This is accomplished by a For loop involving the Output command.

Access L1 by pressing [2nd], [ 1 ].

Examples: Decimal ← → Binary
27 ← → {0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1}
428 ← → {0,0,0,0,0,0,0,1,1,0,1,0,1,1,0,0}
3,245 ← → {0,0,0,0,1,1,0,0,1,0,1,0,1,1,0,1}

DEC2BIN
Decimal to Binary (N → L1)
This program works with any positive integer from 0 to 65,535 - 16 bits. No negative numbers. Note: ending quotes and parenthesis are left out to conserve space.
2/20/2013. 170 bytes.  (updated 7/5/2016)

: Input "N:",N
: If N<0 

: Then
: Pause "INVALID
: Stop
: End
: int(N→N
: N→D
: DelVar L1
: 16→dim(L1
: For(K,0,15
: If 2^(15-K)≤D
: Then
: 1→L1(K+1
: D-2^(15-K→D
: End
: End
: ClrHome
: Output(1,1,N
: Output(1,6,">BIN
: For(K,1,16
: Output(3,K,L1(K
: End
: Pause
: ClrHome


BIN2DEC
Binary to Decimal (L1 → N). Enter a list up to 16 zeroes and ones.
This program works with any positive integer from 0 to 65,535 - 16 bits. No negative numbers. Note: ending quotes and parenthesis are left out to conserve space.
2/20/2013. 160 bytes.


: Input "L1 UP TO 16 BITS:",L1
: If dim(L1)>16
: Then
: Pause "INVALID
: Stop
: End
: While dim(L1) < 16

: augment({0},L1→L1
: End
: 0→N
: For(K,0,15
: N+2^K*L1(16-K→N
: End
: ClrHome
: For(K,1,16
: Output(1,K,L1(K
: End
: Output(3,1,">DEC
: Output(3,6,N
: Pause
: ClrHome


** Edited 12/5/2013.  This is due to an error Stephanie Ison pointed out to me.  Many thanks! - Eddie 

Enjoy!

Eddie


This blog is property of Edward Shore. 2013




27 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. A great reference tool to have, appreciate the contribution for all us math/engineering people :D

    ReplyDelete
  3. A great reference tool to have, appreciate the contribution for all us math/engineering people :D

    ReplyDelete
  4. So is the program supposed to work without ending quotes and parenthesis?

    ReplyDelete
    Replies
    1. Yes. However, ending quotes and parenthesis can be included. The reason why is that pressing ENTER after each line terminates the entry. In programs, line are terminated by colons.

      Hope that helps, Eddie

      Delete
  5. Hi, I have an error when running BIN2DEC program. When i enter a binary value, an error message "Err: Data type" occurs. I choose option "2: go to" to see the error and it points me to the 1st code line " Input "L1 UP TO 16 BITS:",L1", the blinking cursor is after L1. I have checked each line to see if i entered something wrong but i could not find any error. Do you know any solution for this error? I'm using TI 84 plus silver edition.
    And thank you for this great tool

    ReplyDelete
    Replies
    1. Try entering the binary number as a list of bits. For example: 1101 would be entered as {1,1,0,1}.

      Also the L in L1 is the small L (I think it is accessed by 2nd, 4).

      Hope this helps,

      Eddie

      Delete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Great program it will really help me out! Thanks for sharing it.

    ReplyDelete
    Replies
    1. I just noticed that mine doesn't work right. it says 10000 and 10001 are 16. It does that for other numbers too? 1110 and 1111 both come up as 14?

      Delete
    2. Hi Stephanie,

      Thank you for pointing this out to me - truly appreciate it.

      I think I found the error in my program.

      In comparing what is typed and what is on my TI-84+, the line "For(K, 1, 15" should be "For(K, 0, 15". This should give the correct results. I will edit the blog entry to reflect this.

      Eddie

      Delete
  8. I'm just an enthusiast, not a programer, so this may seem arbitrary, but I was confused on the purpose of this string and how to enter it "16 data-blogger-escaped-br="">:"

    ReplyDelete
    Replies
    1. Brett,

      The "16 data-blogger-escaped-br"">:" is not supposed to be there. Honestly I have no idea how that happened.

      It should be erased and looks like it supposed to now.

      Eddie

      Delete
  9. I get an error and it goes to the 1 on :16->dim(L1

    ReplyDelete
    Replies
    1. never mind. need to access L1 by 2nd 1 and not typing it in

      Delete
  10. Very firstly you can make more money from online. for more money you need to use Binary option trading. If you agree that make money by Binary option then you need to use Binary option bot Trend Trader. Trend Trader is really nice software. it will help you to make more money from forex trading. and minimize your loss. You can check by visiting their official website: Trend Trader Official Website

    ReplyDelete
  11. If you're actually searching for none risk plan to make money online I can show you the software which is extremely safer and how anyone can start profiting with Trend Trader. Check by visiting their Trend Trader Official Website

    ReplyDelete

  12. Today I want to share my personal experience that helps my business. It is a great surprise for all traders. First time, I applied Pro Robot but I got bad output, loss and many time fake signals. Then I got free binary video tutorials of Trend Trader from my friend. The Trend Trader is new version, so easy, always provides me right time signal to buy or sell and auto earning. The Pro Robot gives me 15%”25% profit before Trend Trader gives me 55%”80% profit till now. I took my product price only 1 day by using The Trend Trader after that it brings only profit to me. I recommend you that Trend Trader has a customer support also. You can check by visiting their official website Trend Trader Official Website

    ReplyDelete
  13. Get a forex dealing trading program that can successfully improve your dealing from trend trader review generating forex styles and styles to the dealing itself. Of course, if you want a forex dealing trading program, you would most likely want something that can do everything for you as well.

    ReplyDelete
  14. http://www.binarydecimal.com/
    This is website where you can convert any number from one numeral system to another.
    example
    http://www.binarydecimal.com/110000110011-binary/
    For example you can convert Binary to Decimal or Binary to Hexadecimal or Hexadecimal to Binary. In fact you can convert any Numeral system to any other Numeral system. We accept more that 30 base systems.

    ReplyDelete
  15. I cannot get either program to work on my ti-84 plus CE

    ReplyDelete
    Replies
    1. BIN2DEC takes me to the end of line 1 and DEC2BIN Takes mt to N<0 on line 2

      Delete
    2. BIN2DEC takes me to the end of line 1 and DEC2BIN Takes mt to N<0 on line 2

      Delete
    3. 1. DEC2BIN: I revised the first three lines to:

      : Input "N:",N
      : If N<0
      : Then

      2. BIN2DEC: Remember to enter the binary number as a list of zeroes and ones. Example: For 1101, enter {1,1,0,1}

      Eddie

      Delete
  16. Based on the picture. How do you should the decimal value before it shows the binary value?

    ReplyDelete

HP Prime and TI-84 Plus: Basic Wheatstone Full Bridge Circuit

HP Prime and TI-84 Plus:  Basic Wheatstone Full Bridge Circuit The program WHEATSTONE (HP Prime) and WHTSTONE (TI-84 Plus CE) deals wi...