Post Reply 
[42S] looking for decimal to rational fraction
01-18-2019, 12:26 AM
Post: #5
RE: [42S] looking for decimal to rational fraction
(01-17-2019 11:38 PM)cdmackay Wrote:  I was looking for a program to do decimal to fraction conversion on the 42S (well, DM42).

I found this older thread, where user Xose posts a link to his code at a now defunct website.

The Internet Archive had a single copy of that page here, but it contains some odd characters, and I'm unsure how to deal with them.

You can see them at the link, and here's an excerpt from the downloaded file:

Code:
00 { 163-Byte Prgm }

01<B7>LBL "FRACT"
02 XEQ 11
03 ENTER
04 FP
05 12
06 X<>Y
07 X=0?
08 Rv
09 Rv
10 +/-
11 10^X
12 2
13 <F7>
14 STO 01
15 Rv
16 STO 05
17 ENTER
18 ABS
19 STO 00
20 <F7>
21 STO 04

see e.g. lines 1, 13 & 20.

How do I enter those? Or is the listing corrupted?

thanks very much…

Use right-click "View Frame Source" in the Chrome browser to get a better view of the source. The funny characters before the LBL are just to make the labels stand out on the listing and can be ignored. The characters on lines 13 and 20 are the 'divide' operator.

Code:
******************************

FRACT for the HP42S

00 { 163-Byte Prgm }

01·LBL "FRACT"
02 XEQ 11
03 ENTER
04 FP
05 12
06 X<>Y
07 X=0?
08 Rv
09 Rv
10 +/-
11 10^X
12 2
13 ÷
14 STO 01
15 Rv
16 STO 05
17 ENTER
18 ABS
19 STO 00
20 ÷
21 STO 04
22 1
23 STO 02
24 CLX
25 STO 03
26 RCL 00
27·LBL 00
28 RCL 00
29 RCL× 02
30 ENTER
31 ENTER
32 2
33 1/X
34 +
35 XEQ 10
36 -
37 ABS
38 RCL 01
39 RCL× 02
40 X>Y?
41 GTO 01
42 Rv
43 Rv
44 1/X
45 ENTER
46 IP
47 ABS
48 RCL× 02
49 RCL+ 03
50 RCL 02
51 STO 03
52 Rv
53 STO 02
54 Rv
55 FP
56 GTO 00
57·LBL 01
58 RCL 00
59 RCL× 02
60 2
61 1/X
62 +
63 XEQ 10
64 RCL× 04
65 CLA
66 AIP
67 +"/"
68 RCL 02
69 AIP
70 ÷
71 STO 00
72 RCL- 05
73 +" ("
74 X=0?
75 +"=)"
76 X>0?
77 +">)"
78 X<0?
79 +"<)"
80 XEQ 12
81 AVIEW
82 RTN
83·LBL 10
84 X>=0?
85 GTO 02
86 1
87 -
88·LBL 02
89 IP
90 RTN
91·LBL 11
92 STO 10
93 Rv
94 STO 09
95 Rv
96 STO 08
97 Rv
98 STO 07
99 Rv
100 RTN
101·LBL 12
102 RCL 07
103 RCL 08
104 RCL 09
105 RCL 10
106 RTN
107 END

******************************

FRACT for the HP41C

01·LBL "FRACT"
02 ENTER^
03 FRC
04 12
05 X<>Y
06 X=0?
07 RDN
08 RDN
09 CHS
10 10^X
11 2
12 /
13 STO 01
14 RDN
15 STO 05
16 ENTER^
17 ABS
18 STO 00
19 /
20 STO 04
21 1
22 STO 02
23 CLX
24 STO 03
25 RCL 00
26·LBL 00
27 RCL 00
28 RCL 02
29 *
30 ENTER^
31 ENTER^
32 2
33 1/X
34 +
35 XEQ 10
36 -
37 ABS
38 RCL 01
39 RCL 02
40 *
41 X>Y?
42 GTO 01
43 RDN
44 RDN
45 1/X
46 ENTER^
47 INT
48 ABS
49 RCL 02
50 *
51 RCL 03
52 +
53 RCL 02
54 STO 03
55 RDN
56 STO 02
57 RDN
58 FRC
59 GTO 00
60·LBL 01
61 RCL 00
62 RCL 02
63 *
64 2
65 1/X
66 +
67 XEQ 10
68 RCL 04
69 *
70 RCL 02
71 RTN
72·LBL 10
73 CHS
74 X<=0?
75 GTO 02
76 1
77 -
78·LBL 02
79 INT
80 CHS
81 RTN

— Ian Abbott
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [42S] looking for decimal to rational fraction - ijabbott - 01-18-2019 12:26 AM



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