Post Reply 
Feet/Feet-Inch-Fraction Conversions (compact format)
10-22-2018, 12:06 AM (This post was last modified: 10-23-2018 01:17 PM by Eddie W. Shore.)
Post: #1
Feet/Feet-Inch-Fraction Conversions (compact format)
The two functions presented on this blog entry are FIFT (feet-inches-sixteenth of inches to feet) and FTFI (feet to feet-inches-sixteenth of inches). The format of the feet-inches-sixteenth of inches are as follows:

FF: feet
II: inches
NN: sixteenth of an inch

Example: 4.0107 -> 4 feet 1 inch 7/16
Example: 5.1108 -> 5 feet 11 inches 1/2
Example: 3.06142 -> 3 feet 6 inches 14.2/16

There is no rounding or fraction simplification involved with this format.

HP Prime Program FIFT: FF.IINN to Feet

Code:

EXPORT FIFT(X)
BEGIN
// 2018-10-08 EWS
// FF.II16 → FEET
LOCAL Y,Z;
Y:=100*FP(X);
Y:=(IP(Y)+100*FP(Y)/16)/12;
Z:=IP(X)+Y;
RETURN Z;
END;

Examples:

FIFT(6.111) returns 6.96875 (6 ft 11 in 10/16 -> 6.96875 ft)
FIFT(0.0808) returns 0.70833333333 (8 in 8/16 (8 in 1/2) -> 0.70833333333 ft)

HP Prime Program FTFI: Feet to FF.IINN

Code:

EXPORT FTFI(X)
BEGIN
// 2018-10-08 EWS
// FEET → FF.II16
LOCAL Y,Z;
Y:=FP(X)*12;
Z:=IP(Y)/100; 
Y:=FP(Y)*16/10000;
Z:=IP(X)+Z+Y;
RETURN Z;
END;

Examples:
FTFI(5.78125) returns 5.0906 (5.78125 ft -> 5 ft 9 in 6/16 (5 ft 9 in 3/8))
FTFI(4.05) returns 4.00096 (4.05 ft -> 4 ft 9.6/16 in)

Link to blog post: https://edspi31415.blogspot.com/2018/10/...ction.html
Visit this user's website Find all posts by this user
Quote this message in a reply
10-23-2018, 04:48 PM
Post: #2
RE: Feet/Feet-Inch-Fraction Conversions (compact format)
It would be nice if both FTFI and FIFT can be combined as one, say feet()

Float 6.111 is very hard to know its meaning. 6.111 ft ? 6 ft 11 in 10/16 ?

I propose use imaginary number to signal the difference, a signal for multiple units (ft, in, 16th)

6 + 1110 i = 6 ft 11 in 10/16
6.111 = 6.111 ft

Example: what is 5.78125 ft + (6 ft 11 in 10/16) ?

feet(5.78125 + 6 + 1110 i) => 12.75 ft
feet(12.75) => 12 + 900 i (12 ft 9 in)
Find all posts by this user
Quote this message in a reply
11-28-2018, 10:15 PM
Post: #3
RE: Feet/Feet-Inch-Fraction Conversions (compact format)
(10-23-2018 04:48 PM)Albert Chan Wrote:  Float 6.111 is very hard to know its meaning. 6.111 ft ? 6 ft 11 in 10/16 ?

I propose use imaginary number to signal the difference, a signal for multiple units (ft, in, 16th)
[snip]

Another alternative.
Find all posts by this user
Quote this message in a reply
Post Reply 




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