HP Forums

Full Version: (15C) Binary to Decimal Conversion
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
HP 15C: Binary to Decimal Conversion

Link: http://edspi31415.blogspot.com/2016/01/h...rsion.html

Input: A number in binary form. Maximum value: 1 111 111 111 (1,023 in decimal).

Registers used:

R0 = number in binary
R1 = number in decimal
R2 = counter

I have this program under label C.

Program:

Code:
LBL C
STO 0
LOG
INT
1
+
3
10^X
÷ 
STO 2
0
STO 1
LBL 3
RCL 0
RCL 2
INT
1
+
10^X
÷
FRAC
1
0
*
INT
2
ENTER
RCL 2
INT
Y^X
*
STO+ 1
ISG 2
GTO 3
RCL 1
Cf. (HP-11C) Base Conversion

For this specific case you can use the constants 2 and 10 instead of registers 1 and 2.

Code:
STO 0
8
x<>y
LBL 0
2
x<>y
1
0
÷
INT
x=0
GTO 1
R↓
×
R↓
×
STO- 0
R↓
GTO 0
LBL 1
RCL 0

Cheers
Thomas
(01-10-2016 10:09 PM)Eddie W. Shore Wrote: [ -> ]Link: http://edspi31415.blogspot.com/2016/01/h...rsion.html

Examples:
Binary: 10101, Decimal: 42

Should be 21.
(01-11-2016 10:00 PM)Thomas Klemm Wrote: [ -> ]
(01-10-2016 10:09 PM)Eddie W. Shore Wrote: [ -> ]Link: http://edspi31415.blogspot.com/2016/01/h...rsion.html

Examples:
Binary: 10101, Decimal: 42

Should be 21.

Well, that's only off by a factor of 10...
Reference URL's