[hp15c]

HP15c program: number conversion dec->binary


command         display

f LBL D        001-42,21,14
   0            002-       0
   STO 0        003-   44  0
   STO 1        004-   44  1
   R_arrow_down 005-      33
f LBL 8        006-42,21, 8
   1            007-       1
   STO + 0      008-44,40, 0
   R_arrow_down 009-      33
   2            010-       2
   ÷            011-      10
   Enter        012-      36
g INT          013-43    44
g TEST 9       014-43,30, 9
   GTO 8        015-   22  8
   RCL 0        016-   45  0
   1            017-       1
   -            018-      30
   10^x         019-      13
   STO + 1      020-44,40, 1
   R_arrow_down 021-      33
g TEST 1       022-43,30, 1
   GTO 8        023-   22  8
   RCL 1        024-   45  1
g RTN          025-   43 32

This program uses the following label: LBL D and LBL 8
This program uses the following registers (STO/RCL): 0, 1

Using the program

This program can convert decimal numbers between 1 and 1023 into their binary representation.

I start every program with a label. This way you can have a number of programs in your 15c and you just select which one to run by pressing f LABELNAME (f D in this case) or GSB LABELNAME (GSB D in this case).

Let's say you would like to convert decimal 19 into its binary representation.
You type: 19, GSB D
The display shows "running" and then you see: 10011

Algorithm

19 / 2 = 9 remainder 1
9 / 2  = 4 remainder 1
4 / 2  = 2 remainder 0
2 / 2  = 1 remainder 0
1 / 2  = 0 remainder 1

The result consists of the remainders read from bottom to top: 10011


© Guido Socher