Post Reply 
number base conversion for hp17b/17bii
06-18-2014, 06:53 PM
Post: #1
number base conversion for hp17b/17bii
OK, you've got your old 17b or 17bii you use for all your financial needs, but now you need something to do number base conversions. There is no need to go to a scientific model, the solver is your friend.

B1 = old base (2-10)
B2 = new base (2-10)
N = number to convert
ANS = solve for this

Either B1 or B2 must be 10.

BC:ANS=\(\Sigma\)(I:0:LOG(N)\(\div\)LOG(B2):1:MOD(N:B2)\(\times\)B1I+0\(\times\)L(N:IDIV(N:B2))​)
Find all posts by this user
Quote this message in a reply
06-19-2014, 01:59 AM (This post was last modified: 06-19-2014 08:55 AM by Thomas Klemm.)
Post: #2
RE: number base conversion for hp17b/17bii
(06-18-2014 06:53 PM)Don Shepherd Wrote:  BC:ANS=\(\Sigma\)(I:0:LOG(N)\(\div\)LOG(B2):1:MOD(N:B2)\(\times\)B1I+0\(\times\)L(N:IDIV(N:B2))​)

Very cool! Thanks for consistently bringing up this calculator.
You don't need MOD if you combine the calculations from successive lines.

Example: DEC → OCT
Code:
         2014
+   2 *   251
+  20 *    31
+ 200 *     3
         ----
         3736

BC:ANS=
0\(\times\)L(K:FROM-TO)
+N
+\(\Sigma\)(I:1:LOG(N)\(\div\)LOG(TO):1:
  G(K)\(\times\)L(N:IDIV(N:TO))
  +0\(\times\)L(K:FROM\(\times\)G(K))
​)


Kind regards
Thomas
Find all posts by this user
Quote this message in a reply
06-19-2014, 09:06 AM
Post: #3
RE: number base conversion for hp17b/17bii
A little shorter:

BC:ANS=
N+
(FROM-TO)\(\times\)
\(\Sigma\)(I:0:LOG(N)\(\div\)LOG(TO):1:
  L(N:IDIV(N:TO))\(\times\)FROM^I
​)
Find all posts by this user
Quote this message in a reply
06-19-2014, 01:45 PM
Post: #4
RE: number base conversion for hp17b/17bii
(06-19-2014 09:06 AM)Thomas Klemm Wrote:  A little shorter:

BC:ANS=
N+
(FROM-TO)\(\times\)
\(\Sigma\)(I:0:LOG(N)\(\div\)LOG(TO):1:
  L(N:IDIV(N:TO))\(\times\)FROM^I
​)

Thomas, that is way cool! Thanks.

The method I chose was based on how I learned to manually convert numbers from one base to another back in computer programming school in 1968. That method is described at the bottom of this page. I just converted those manual steps to an equivalent solver equation.

I like your method also, it is simple and elegant.

Don
Find all posts by this user
Quote this message in a reply
06-19-2014, 02:06 PM
Post: #5
RE: number base conversion for hp17b/17bii
(06-18-2014 06:53 PM)Don Shepherd Wrote:  Either B1 or B2 must be 10.

You could set either B1 or B2 to 100. This allows conversions between HEX and DEC.

Example: CAFEHEX
B1: 16
B2: 100
N: 12101514
ANS: 51,966
Find all posts by this user
Quote this message in a reply
06-19-2014, 02:36 PM
Post: #6
RE: number base conversion for hp17b/17bii
(06-19-2014 02:06 PM)Thomas Klemm Wrote:  
(06-18-2014 06:53 PM)Don Shepherd Wrote:  Either B1 or B2 must be 10.

You could set either B1 or B2 to 100. This allows conversions between HEX and DEC.

Example: CAFEHEX
B1: 16
B2: 100
N: 12101514
ANS: 51,966

I am stunned! I never thought that was possible. You are a true missle-man.
Find all posts by this user
Quote this message in a reply
06-19-2014, 10:15 PM
Post: #7
RE: number base conversion for hp17b/17bii
(06-19-2014 02:36 PM)Don Shepherd Wrote:  I am stunned! I never thought that was possible.

It's been there for a while: Base Conversion for HP-11C
Find all posts by this user
Quote this message in a reply
06-21-2014, 10:18 PM
Post: #8
RE: number base conversion for hp17b/17bii
Here's a program for the HP-12C:
Code:
01 -       36  ENTER
02 -       36  ENTER
03 -    45 15  RCL FV
04 -       10  ÷
05 -    43 25  INTG
06 -    43 13  CFo
07 -    45 15  RCL FV
08 -       10  ÷
09 -    43 25  INTG
10 -    43 35  x=0
11 - 43,33 14  GTO 14
12 -    43 14  CFj
13 - 43,33 07  GTO 07
14 -       33  R↓
15 -        1  1
16 -    45 14  RCL PMT
17 -       22  1/x
18 -       24  Δ%
19 -    44 12  STO i
20 -       33  R↓
21 -       33  R↓
22 -    42 13  NPV
23 -    45 14  RCL PMT
24 -    45 15  RCL FV
25 -       30  −
26 -       20  ×
27 -       40  +

Example: 201410 → 37368
10 STO PMT
8 STO FV
2014 R/S
Find all posts by this user
Quote this message in a reply
06-21-2014, 11:27 PM
Post: #9
RE: number base conversion for hp17b/17bii
(06-21-2014 10:18 PM)Thomas Klemm Wrote:  Here's a program for the HP-12C:
Code:
01 -       36  ENTER
02 -       36  ENTER
03 -    45 15  RCL FV
04 -       10  ÷
05 -    43 25  INTG
06 -    43 13  CFo
07 -    45 15  RCL FV
08 -       10  ÷
09 -    43 25  INTG
10 -    43 35  x=0
11 - 43,33 14  GTO 14
12 -    43 14  CFj
13 - 43,33 07  GTO 07
14 -       33  R↓
15 -        1  1
16 -    45 14  RCL PMT
17 -       22  1/x
18 -       24  Δ%
19 -    44 12  STO i
20 -       33  R↓
21 -       33  R↓
22 -    42 13  NPV
23 -    45 14  RCL PMT
24 -    45 15  RCL FV
25 -       30  −
26 -       20  ×
27 -       40  +

Example: 201410 → 37368
10 STO PMT
8 STO FV
2014 R/S

That is just amazing, Thomas. I'm sure the creators of NPV and delta-percent on the 12c never envisioned those functions being used for number base conversions.

I tip my hat to you, you are "da man".
Find all posts by this user
Quote this message in a reply
06-21-2014, 11:54 PM (This post was last modified: 06-22-2014 12:26 AM by Thomas Klemm.)
Post: #10
RE: number base conversion for hp17b/17bii
But then I realized that the 1:1 translation of my HP-11C program was shorter. And it uses only 3 registers. However it was fun to figure it out.

Addendum:
As long as the from-base PMT doesn't change the following lines could be removed:
Code:
15 -        1  1
16 -    45 14  RCL PMT
17 -       22  1/x
18 -       24  Δ%
19 -    44 12  STO i
20 -       33  R↓
21 -       33  R↓
With this we are at the same number of lines.
Of course you still have to calculate i once and store it.

(06-21-2014 11:27 PM)Don Shepherd Wrote:  That is just amazing, Thomas. I'm sure the creators of NPV and delta-percent on the 12c never envisioned those functions being used for number base conversions.

I've seen this trick in Valentin's paper: HP-12C’s Serendipitous Solver
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)