First issue
This commit is contained in:
140
q2x.free42
Normal file
140
q2x.free42
Normal file
@@ -0,0 +1,140 @@
|
||||
00 { 164-Byte Prgm }
|
||||
|
||||
01 LBL "Q2F"
|
||||
|
||||
02 SIZE 25
|
||||
03 CLRG
|
||||
|
||||
// Save Stack
|
||||
04 STO 01
|
||||
05 R↓
|
||||
06 STO 02
|
||||
07 R↓
|
||||
08 STO 03
|
||||
09 R↓
|
||||
10 STO 04
|
||||
11 R↓
|
||||
|
||||
// Get precision
|
||||
12 8
|
||||
13 FS? 36
|
||||
14 STO+ 05
|
||||
15 4
|
||||
16 FS? 37
|
||||
17 STO+ 05
|
||||
18 2
|
||||
19 FS? 38
|
||||
20 STO+ 05
|
||||
21 1
|
||||
22 FS? 39
|
||||
23 STO+ 05
|
||||
24 RCL 05
|
||||
// If precision is 0, set default to 9
|
||||
25 X=0?
|
||||
26 9
|
||||
27 +/-
|
||||
28 10↑X
|
||||
29 STO 05
|
||||
|
||||
// Init counter
|
||||
30 10
|
||||
31 1000
|
||||
32 ÷
|
||||
33 0.00001
|
||||
34 +
|
||||
35 STO 06
|
||||
36 10
|
||||
37 STO 07
|
||||
|
||||
38 CLST
|
||||
39 RCL 01
|
||||
|
||||
// [[A]] [LOOP-BEGIN] Build continued fraction
|
||||
40 LBL A
|
||||
41 ENTER
|
||||
42 IP
|
||||
43 STO IND 07
|
||||
44 X<>Y
|
||||
45 FP
|
||||
46 STO 08
|
||||
|
||||
// Check if configured tolerance is reached --> goto B
|
||||
47 RCL 05
|
||||
48 X>Y?
|
||||
49 GTO B
|
||||
// .. if not, roll-down check value
|
||||
50 R↓
|
||||
// ... and invert result for next round
|
||||
51 1/X
|
||||
|
||||
// Increase REG-index
|
||||
52 1
|
||||
53 STO+ 07
|
||||
54 R↓
|
||||
|
||||
// Proceed, if max num of rounds is reached --> repeat A
|
||||
55 ISG 06
|
||||
56 GTO A
|
||||
// [LOOP-END] Build continued fraction
|
||||
57 GTO C
|
||||
|
||||
// [[B]] FINISHED building continued fraction by tolerance
|
||||
58 LBL B
|
||||
// Remove last stack entry used for tolerance check
|
||||
59 R↓
|
||||
|
||||
// [[C]] FINISHED building continued fraction by max num of rounds
|
||||
60 LBL C
|
||||
|
||||
// Init loop for reverse calculation from old value
|
||||
61 RCL 06
|
||||
62 IP
|
||||
63 0.00001
|
||||
64 +
|
||||
65 STO 06
|
||||
|
||||
// Start calculation of final fraction
|
||||
// NOTE: 1. fraction always has nominator =1
|
||||
66 CLST
|
||||
67 1
|
||||
68 RCL IND 07
|
||||
69 PRSTK
|
||||
|
||||
// [[D]] [LOOP-BEGIN] Reverse calculation
|
||||
70 LBL D
|
||||
71 ENTER
|
||||
72 R↓
|
||||
73 X<>Y
|
||||
74 R↑
|
||||
|
||||
// Decrease REG-index
|
||||
75 1
|
||||
76 STO- 07
|
||||
77 CLX
|
||||
|
||||
78 RCL IND 07
|
||||
79 ×
|
||||
80 +
|
||||
81 PRSTK
|
||||
|
||||
82 DSE 06
|
||||
83 GTO D
|
||||
// [LOOP-END] Perform reverse calculation
|
||||
|
||||
// Prepare Alpha-Register
|
||||
84 CLA
|
||||
85 AIP
|
||||
86 X<>Y
|
||||
87 ⊢"/"
|
||||
88 AIP
|
||||
|
||||
// Revert Stack
|
||||
89 RCL 04
|
||||
90 RCL 03
|
||||
91 RCL 02
|
||||
92 RCL 01
|
||||
|
||||
// Show Result
|
||||
//90 AVIEW
|
||||
|
||||
93 END
|
||||
Reference in New Issue
Block a user