Post Reply 
(12C) Add or Subtract Fractions
09-24-2018, 05:24 PM (This post was last modified: 09-24-2018 06:40 PM by Dieter.)
Post: #5
RE: (12C) Add or Subtract Fractions
(09-19-2018 07:55 AM)Gamo Wrote:  Continue form post #1

Here is the "Multiply and Divide Fractions" program.

You can have both programs at the same time, even on a 12C.

(09-19-2018 07:55 AM)Gamo Wrote:  Remark: This Multiply or Divide program will not work with negative fractions.

This one will:

Code:
01 STO 4
02 R↓
03 STO 3
04 R↓
05 STO 2
06 R↓
07 STO 1
08 CLX
09 R/S
10 1
11 -
12 X=0?
13 GTO 27
14 1
15 -
16 X=0?
17 GTO 29
18 1
19 -
20 X=0?
21 GTO 41
22 1
23 -
24 X=0?
25 GTO 44
26 GTO 08
27 RCL 3   add
28 GTO 31
29 RCL 3   subtract
30 CHS
31 RCL 2
32 x
33 RCL 1
34 RCL 4
35 x
36 +
37 RCL 2
38 RCL 4
39 x
40 GTO 51
41 RCL 4   multiply
42 RCL 3
43 GTO 46
44 RCL 3   divide
45 RCL 4
46 RCL 1
47 x
48 X<>Y
49 RCL 2
50 x
51 STO 2   store result
52 X<>Y    in R2 (denominator)
53 STO 1   and R1 (numerator)
54 ENTER   GCD loop starts here
55 ENTER
56 CLX
57 +
58 R↓
59 ÷
60 LstX
61 X<>Y
62 INTG
63 x
64 -
65 X=0?
66 GTO 68
67 GTO 54
68 +
69 STO÷1   reduce
70 STO÷2   fraction
71 RCL 1
72 PSE     display numerator
73 RCL 1
74 RCL 2
75 R/S     display denominator
76 X=0?
77 GTO 79  if input was zero, convert to mixed fraction
78 GTO 01  else continue calculation with new data
79 RCL 1
80 RCL 2
81 ÷
82 INTG
83 PSE
84 RCL 2
85 x
86 RCL 1
87 X<>Y
88 -
89 PSE
90 GTO 73

Enter program, switch back to run mode, f [PRGM] to reset.

Usage:
1. Enter both fractions:
a [ENTER] b [ENTER] c [ENTER] d
[R/S] => 0

2. Enter command code:
1 = add
2 = subtract
3 = multiply
4 = divide
[R/S]

3. Result is displayed as "numerator", denominator.

4. Now you can do one of the following:

4a. Convert result to mixed fraction:
Enter 0 [R/S]
=> "whole part", "numerator", denominator
Continue with step 4.

4b. Enter another fraction e/f to be added/subtracted/multiplied/divided:
e [ENTER] f [R/S]
Continue with step 2.

4c. Start a completely new calculation:
Continue with step 1.

(09-19-2018 07:55 AM)Gamo Wrote:  Try this challenging example: 676/13 x 3117/22

Answer: 81042/11 or 7367+ 5/11

676 [ENTER] 13 [ENTER] 3117 [ENTER] 22
[R/S] => 0
3 [R/S]
=> "81042" 11

Convert this into a mixed fraction:
0 [R/S]
=> "7367" "5" "11"

Now add 1/22
1 [ENTER] 22 [R/S]
1 [R/S]
=> "14735" 2

Finally subtract 1/4
1 [ENTER] 4 [R/S]
2 [R/S]
=> "29469" 4

View this as a mixed fraction:
0 [R/S]
=> "7367" "1" 4

New calculation: 1/3 – 2/5
1 [ENTER] 3 [ENTER] 2 [ENTER] 5 [R/S]
2 [R/S]
"1" –15

Add 1/25
1 [ENTER] 25 [R/S]
1 [R/S]
"–2" 75

Re. memory uisage:
g MEM yields P–92  r–08
No registers beyond R4 are used.

Dieter

Edit: replaced program with a slightly modified version, now down to 90 steps.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(12C) Add or Subtract Fractions - Gamo - 09-17-2018, 05:49 AM
RE: (12C) Add or Subtract Fractions - Gamo - 09-19-2018, 07:55 AM
RE: (12C) Add or Subtract Fractions - Dieter - 09-24-2018 05:24 PM
RE: (12C) Add or Subtract Fractions - Gamo - 09-25-2018, 02:36 AM



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