09-24-2015, 11:56 PM
HP 15c x/16
Program to convert decimal fraction to a fraction readable on a tape measure:
Registers:
STO 0- ORIGINAL NUMBER
STO 1- NUMERATOR
STO 2- DENOMINATOR
Program to convert decimal fraction to a fraction readable on a tape measure:
Registers:
STO 0- ORIGINAL NUMBER
STO 1- NUMERATOR
STO 2- DENOMINATOR
Code:
01 LBL A
02 STO 0
03 FRAC //Creates numerator x as a fraction
//with 16 as denominator: x/16
04 1 //Use 32 ON steps 04-05 if you want 32nds
05 6
06 STO 2
07 *
08 FIX 0
09 RND
10 FIX 3
11 INT
12 STO 1
13 LBL 7 //Can fraction be reduced?
14 2
15 /
16 FRAC
17 TEST 0 //Same as X#0
18 GTO 8 //If fraction can't be reduced,
//go to formatting subroutine
19 RCL 2 //Reduce fraction
20 2
21 /
22 STO 2
23 RCL 1
24 2
25 /
26 STO 1
27 GTO 7 //Try again
28 LBL 8 //Formatting subroutine
29 RCL 0 //Original number will be left in y register
30 RCL 1 //The next 7 steps put the fraction
//into the format Num.Deno:
31 RCL 2 //For Example, 1/16 will display
//as 1.16, 5/8 as 5.08
32 .
33 0
34 1
35 *
36 +
37 RTN