Re: HP25 Applications Programs (was: programming challenge for HP-12c Message #21 Posted by Eamonn on 27 June 2004, 4:32 p.m., in response to message #14 by Vieira, Luiz C. (Brazil)
Hi Luiz,
I had a look at the programs in the HP-25 Applications programs book. They use a very interesting approach and it's easy to adapt them to the HP-12C.
The program to convert from base b to base 10 is broken into two parts, one for the integer part and one for the fractional part. Both parts require the user to input one digit at a time, starting from the rightmost digit, and press R/S after digit. Once the integer part of the number has been calculated, the second part of the program is used to calculate the fractional part. It's not quite as elegant as entering the entire number at once and letting the calculator go ahead and extract the digits and do the entire conversion. However when you have only 50 program steps, it's a very acceptable compromise.
The program to convert from base 10 to base B takes a very unusual approach. It uses a successive approximation algorithm that slowly converges on the answer. It's very interesting to see the calculator figure out the result. However, it doesn't seem to work for all values. For example, 5.5 in base 10 should be 5.08 in base 16. The program returns 5.07151515 (5.7fff). I tested it on the HP-25 simulator that can be found on the museum website, so it may behave differently on a real HP-25.
Don,
I highly recommend getting the museum DVD. It has scans of the manuals for almost all the machines in the museum, aswell as application handbooks (including the HP-25 application book), articles and a wealth of other information.
I've also attached the HP-12C versions of the programs. The first program is identical to the HP-25 version. The second program did require changes as the HP-25 version uses two conditional instructions that are not present on the HP-12C. However, it suffers from the same inaccuracy as the HP-25 version.
Best Regards,
Eamonn.
Base b to base 10 program. Before running, store the base in R0 and reset the program counter to the top of the program (key in 'f PRGM' when in run mode). Key in the rightmost digit, press R/S. Key in the next digit, press R/S, etc. For the fractional part, set the program counter to step 15 (key in 'GTO 15')
01 STO 1
02 RCL 0
03 Enter
04 Enter
05 Enter
06 RCL 1
07 R/S
08 STO 1
09 CLX
10 +
11 *
12 RCL 1
13 +
14 GTO 07
15 RCL 0
16 1/x
17 STO 2
18 STO 3
19 *
20 R/S
21 RCL 2
22 RCL 3
23 *
24 STO 3
25 *
26 +
27 GTO 20
Base 10 to base b conversion program for the HP-12C. Adapted from the version for the HP-25 in the HP Applications program handbook. Store the base in R0 and the number in R1. Reset the program counter to the top of the program (key in 'f PRGM' when in run mode) and hit R/S. The calculator will display each of the updated approximations. Since the program doesn't terminate, it is necessary to press R/S when the desired degree of accuracy has been achieved. The most recent estimate in in R3.
01 1
02 0
03 STO 2
04 RCL 0
05 x<=y
06 GTO 10
07 E
08 2
09 STO 2
10 0
11 STO 3
12 RCL 1
13 LN
14 RCL 0
15 LN
16 /
17 0
18 x<=y
19 GTO 25
20 Rv (X < 0)
21 INTG
22 1
23 -
24 GTO 27
25 Rv
26 INTG
27 STO 4
28 RCL 2
29 x<>y
30 y^x
31 RCL 3
32 +
33 STO 3
34 PSE
35 RCL 0
36 RCL 4
37 y^x
38 STO -1
39 GTO 12
|