Decimal and Binary Conversions
Programs created 2/20/2013
Decimal to Binary (number → string)
D2B(number)  execute from Home!
EXPORT D2B(N)
BEGIN
LOCAL str1;
D:=INT(N);
L:=INT(LN(D)/LN(2));
str1:="1";
D:=D2^L;
FOR K FROM 1 TO L DO
IF 2^(LK)≤D THEN
str1:=str1+"1";
D:=D2^(LK);
ELSE
str1:=str1+"0";
END;
END;
RETURN str1;
END;
Examples:
D2B(52) returns "110100"
D2B(131) returns "10000011"
Binary to Decimal (string → number)
Run this from Home! B2D(string of 1s and 0s). Attempting to run B2D from the program catalog will cause an error.
EXPORT B2D(str1)
BEGIN
D:=dim(str1);
N:=0;
FOR K FROM 0 TO D1 DO
N:=N+2^K*expr(mid(str1,DK,1));
END;
RETURN N;
END;
Examples:
B2D("11011") returns 27.
B2D("1010110000") returns 688.
Eddie
This blog is property of Edward Shore. 2013
A blog is that is all about mathematics and calculators, two of my passions in life.
Saturday, March 16, 2013
Decimal/Binary Conversions for the HP 39gii
Subscribe to:
Post Comments (Atom)
TI84 Plus CE: Version 5.3 Highlights
TI84 Plus CE: Version 5.3 Highlights Piecewise Function The piecewise( function is added to the Math menu under the math submenu...

Casio fx991EX Classwiz Review Casio FX991EX The next incarnation of the fx991 line of Casio calculators is the fx991 EX. ...

TI36X Pro Review This is a review of the TI36X Pro Calculator by Texas Instruments. History Originally, this was the TI30X Pro that w...

One of the missing features of the TI82/83/84 family is the ability to convert between bases. Here are two programs in TIBasic to help...
No comments:
Post a Comment