Sunday, October 21, 2018

HP Prime: Feet/Feet-Inch-Fraction Conversions (compact format)

HP Prime:  Feet/Feet-Inch-Fraction Conversions  (compact format)

Introduction

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

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


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)

Eddie

All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.

Spotlight: Sharp EL-5200

  Spotlight: Sharp EL-5200 As we come on the 13 th (April 16) anniversary of this blog, I want to thank you. Blogging about mathematic...