Post Reply 
(12C) Decimal to Fraction
08-10-2018, 12:28 PM (This post was last modified: 08-10-2018 12:47 PM by Dieter.)
Post: #40
RE: (12C) Decimal to Fraction
(08-09-2018 06:38 PM)Thomas Klemm Wrote:  Very nice! This is my attempt to translate your program for the HP-11C:

Service: here is a translation for the 12C.

Not available tests have been substituted, nmax is stored in the n-register, so that R1 is free and R2...R7 can move down to R1...R6. The output order has been reversed so that the numerator is returned in X and the denominator in Y.

Code:
01 STO 0
02 INTG
03 STO 1
04 1
05 STO 2
06 STO 3
07 RCL 0
08 FRAC
09 x=0?
10 GTO 66
11 Clx
12 STO 4
13 RCL 1
14 RCL 3
15 +
16 STO 5
17 RCL n
18 RCL 2
19 RCL 4
20 +
21 STO 6
22 x≤y?
23 GTO 25
24 GTO 47
25 RCL 5
26 RCL 0
27 RCL 6
28 *
29 x≤y?
30 GTO 36
31 RCL 5
32 STO 1
33 RCL 6
34 STO 2
35 GTO 13
36 -
37 x=0?
38 GTO 44
39 RCL 5
40 STO 3
41 RCL 6
42 STO 4
43 GTO 13
44 RCL 6
45 RCL 5
46 GTO 00
47 RCL 0
48 RCL 3
49 RCL 4
50 /
51 -
52 ENTER
53 x
54 RCL 0
55 RCL 1
56 RCL 2
57 /
58 -
59 ENTER
60 x
61 x≤y?
62 GTO 66
63 RCL 4
64 RCL 3
65 GTO 00
66 RCL 2
67 RCL 1
68 GTO 00

The max. denominator is set with the [n] key.
Output: numerator [X↔Y] denominator.

99 [n]
3,141592654 [R/S] => 311 [X↔Y] 99

2 [√x] [R/S] => 140 [X↔Y] 99

1 [ex] [R/S] => 193 [X↔Y] 71

20 [n]
1 [ex] [R/S] => 49 [X↔Y] 18

700 [n]
2 [√x] [R/S] => 816 [X↔Y] 577

999 [n]
3,141592654 [R/S] => 355 [X↔Y] 113

Now I wonder how long all this takes on an original hardware 12C... ;-)

Note:
You may replace line 23 with an x=0? test. This yields an x≤y? x=0? combination, and since x is always > 0 at this point the result logically is the desired x>y? test. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(12C) Decimal to Fraction - Gamo - 08-06-2018, 12:33 PM
RE: (12C) Decimal to Fraction - Dieter - 08-06-2018, 08:44 PM
RE: (12C) Decimal to Fraction - Dieter - 08-07-2018, 07:29 AM
RE: (12C) Decimal to Fraction - Dieter - 08-07-2018, 01:02 PM
RE: (12C) Decimal to Fraction - Dieter - 08-07-2018, 11:38 AM
RE: (12C) Decimal to Fraction - Gamo - 08-07-2018, 09:29 AM
RE: (12C) Decimal to Fraction - Joe Horn - 08-07-2018, 06:28 PM
RE: (12C) Decimal to Fraction - Dieter - 08-07-2018, 07:10 PM
RE: (12C) Decimal to Fraction - Joe Horn - 08-08-2018, 12:28 AM
RE: (12C) Decimal to Fraction - Dieter - 08-08-2018, 07:04 PM
RE: (12C) Decimal to Fraction - Dieter - 08-09-2018, 09:27 AM
RE: (12C) Decimal to Fraction - Dieter - 08-08-2018, 09:44 PM
RE: (12C) Decimal to Fraction - Gamo - 08-09-2018, 12:51 AM
RE: (12C) Decimal to Fraction - Dieter - 08-09-2018, 07:46 AM
RE: (12C) Decimal to Fraction - Dieter - 08-09-2018, 08:09 AM
RE: (12C) Decimal to Fraction - Gamo - 08-09-2018, 09:16 AM
RE: (12C) Decimal to Fraction - Dieter - 08-09-2018, 10:30 AM
RE: (12C) Decimal to Fraction - Dieter - 08-10-2018 12:28 PM
RE: (12C) Decimal to Fraction - Gamo - 05-07-2019, 01:44 AM
RE: (12C) Decimal to Fraction - Dieter - 08-10-2018, 07:06 PM



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