Post Reply 
(42) Feet inches fractions
06-22-2022, 07:47 PM
Post: #2
RE: (42) Feet inches fractions
For anyone aspiring to pursue the lucrative construction calculator market, here's a fancier version targeting Plus42 (remove the units conversion code in lines 25 to 32 for Free42).

This version uses two variables (both of which will be created and set to default values if not specified by the user):
  • DEN (default 16) specifies the maximum denominator. Should be a power of 2
  • RNDFAC (default 0.5) specifies the rounding factor. Possible values include:
    • 0 (round down to nearest multiple of 1/DEN)
    • 0.4999 (round to nearest multiple of 1/DEN, ties round down)
    • 0.5 (round to nearest multiple of 1/DEN, ties round up)
    • 0.9999 (round up to nearest multiple of 1/DEN)

In addition:
  • Negative numbers are now handled.
  • Zeros display as -. (They were previously blank.)
  • The stack and the previous state of flag 82 should be preserved.
Examples (DEN=16, RNDFAC=0.5, flag 1 clear):
Code:

 12.0000   1' 
 12.4900   1' 1/2"
  1.0000   1"
  1.2500   1-1/4"
 14.0000   1' 2"
 14.0626   1' 2-1/16"
 14.3125   1' 2-5/16"
  4.0010   4"
  7.9990   8"
-21.0625   -1' 9-1/16"
  0.0000   -
14.0000_cm 5-1/2"
 2.0000_yd 6'

Code:

00 { 228-Byte Prgm }
01▸LBL "FIF"
02 FUNC 00
03 CLA
04 RCLFLAG
05 LSTO "F"
06 R↓
07 CF 82
08 SF 25
09 RCL "DEN"
10 FS? 25
11 GTO 06
12 16
13 STO "DEN"
14▸LBL 06
15 R↓
16 SF 25
17 RCL "RNDFAC"
18 FS? 25
19 GTO 08
20 0.5
21 STO "RNDFAC"
22▸LBL 08
23 R↓
24 CF 25
25 UNIT?
26 SKIP
27 GTO 07
28 0_in
29 +
30 UVAL
31▸LBL 07
32 X≤0?
33 "-"
34 ABS
35 RCL× "DEN"
36 RCL+ "RNDFAC"
37 IP
38 RCL÷ "DEN"
39 ENTER
40 FS? 01
41 GTO 00
42 IP
43 X=0?
44 GTO 01
45 12
46 ÷
47 IP
48 X=0?
49 GTO 01
50 AIP
51 ├"' "
52▸LBL 01
53 R↓
54 ENTER
55 ENTER
56 12
57 MOD
58▸LBL 00
59 IP
60 X=0?
61 GTO 02
62 SF 82
63 AIP
64▸LBL 02
65 R↓
66 FP
67 RCL× "DEN"
68 X=0?
69 GTO 05
70 FS? 82
71 ├"-"
72 SF 82
73 LSTO "N"
74 RCL "DEN"
75 LSTO "D"
76▸LBL 03
77 RCL "N"
78 0
79 BIT?
80 GTO 04
81 2
82 STO÷ "D"
83 STO÷ "N"
84 GTO 03
85▸LBL 04
86 RCL "N"
87 AIP
88 ├"/"
89 RCL "D"
90 AIP
91▸LBL 05
92 FS? 82
93 ├"""
94 RCL "F"
95 STOFLAG
96 AVIEW
97 RTN
98 END
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(42) Feet inches fractions - DMaier - 07-11-2021, 08:31 PM
RE: (42) Feet inches fractions - DMaier - 06-22-2022 07:47 PM



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