Post Reply 
(15C) Arithmetic with Fractions
09-23-2018, 09:24 AM (This post was last modified: 09-27-2018 02:19 AM by Gamo.)
Post: #1
(15C) Arithmetic with Fractions
Program to add, subtract, multiply, divide, simplify to lowest term and
convert to mixed fraction.

All procedure is the same from previous post for the
(11C) Arithmetic with Fractions.

This program is the updated version from 11C that improve the computation speed by using better GCD algorithm.

(11C) Arithmetic with Fractions link page at

http://www.hpmuseum.org/forum/thread-11400.html

Here is the clips of this updated version

https://youtu.be/wRrKXyRVof8

Program: 87 program lines
Code:

LBL A    // Store Fractions
STO 4
Rv
STO 3
Rv
STO 2
Rv
STO 1
CLx
RTN
--------------------------------------------------------
LBL B    // Add or Subtract 
RCL 1
RCL 4
x
RCL 2
RCL 3
x
+
STO 5
RCL 2
RCL 4
x
STO 6
GTO 5
-----------------------------------------------------------
LBL C    // Multiply 
RCL 1
RCL 3
x
STO 5
RCL 2
RCL 4
x
STO 6
RCL 5
GTO 5
----------------------------------------------------------
LBL D    // Divide
RCL 1
RCL 4
x
STO 5
RCL 2
RCL 3
x
STO 6
RCL 5
LBL 5    // Reduce Fractions using GCD
ENTER
ENTER
CLx
+
Rv
÷
LSTx
X<>Y
INT
x
-
TEST 0   // X≠0
GTO 5
+
RCL 6
X<>Y
÷
RCL 5
LSTx
÷
RTN
--------------------------------------------------
LBL E    // Mixed Fraction
STO 0
÷
LSTx
X<>Y
ENTER
FRAC
X<>Y
INT
Rv
x
EEX
4
÷
R^
+
FIX 4
RCL 0
X<>Y
RTN

This add-on section is for "Decimal to Fraction" Program

Procedure:

Display X.xxxx.... [GSB] 1 display Numerator [X<>Y] Denominator

If Numerator is larger than Denominator Press [E] for Mixed Fraction

Example: FIX 4

e^1 = 2.7183

[GSB] 1 display 193 [X<>Y] 71

answer is 193/71

[E] display 2.0051 [X<>Y] 71

Mixed Fraction answer is 2+ 51/71

Program: Decimal to Fraction [Total 132 program steps]
Code:

LBL 1
STO 0
STO 1
0
ENTER
ENTER
1
R^
LBL 2
INT
R^
x
+
STO 2
GSB3
X<>Y
÷
RND
RCL 0
RND
X=Y
GTO 4
+
CLx
RCL 2
ENTER
ENTER
R^
RCL 1
FRAC
1/x
STO 1
GTO 2
LBL 4
RCL 2
LBL 3
ENTER
ENTER
RCL 0
x
.
5
+
INT
RTN

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


Messages In This Thread
(15C) Arithmetic with Fractions - Gamo - 09-23-2018 09:24 AM
RE: (15C) Arithmetic with Fractions - Gamo - 09-24-2018, 02:19 AM
RE: (15C) Arithmetic with Fractions - Gamo - 09-25-2018, 02:08 AM
RE: (15C) Arithmetic with Fractions - Gamo - 09-27-2018, 02:14 AM



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