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
Post Reply 


Messages In This Thread
Feet/Feet-Inch-Fraction Conversions (compact format) - Eddie W. Shore - 10-22-2018 12:06 AM



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