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




Casio fx-9750GIII and fx-CG 50: Playing Games with the Probability Simulation Mode

Casio fx-9750GIII and fx-CG 50: Playing Games with the Probability Simulation Mode The Probability Simulation add-in has six type...