Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HP 20S Calc programs?

Status
Not open for further replies.

DemarEngr

Mechanical
May 15, 2003
18
0
0
US
Does anybody have a program on an HP 20S calculator, that converts Decimal's of a foot to Feet Inches with fractions and backwards?

Thanks in Advance
 
Replies continue below

Recommended for you

DemarEngr…

I can't help you directly--I only do RPN and the 20S is algebraic--but I can get you started.

Years ago I wrote a Feet-Inches-Fractions (FIF) program called FEET for the HP-41 that will do what you require and a lot more, and may also be of general interest to other members of this forum. Not only will the program do the two conversions you need, but it will also handle FIF addition and subtraction using a two-register RPN-style stack, FIF*constant and FIF/constant, The program has one storage register and will work with ANY fraction denominator--you are not limited to the binary fractions (i.e. 1/2, 1/4, 1/8, 1/16…). Thus, if you want to work in 1/10 or 1/25 or 1/56, you can. With a few modifications the program will also run on an HP-42S. Several years ago I posted the program listing and instructions on the Museum of HP Calculators (MoHPC):
[The promised update to the program--actually a simplification of the programming technique--was 90% done when my calculator started acting flaky. I have several HP-41 emulators (Windows and Palm), but haven't had the time to finish it.]

Even though you are working with the 20S, you may want to look over my program for techniques.

Now down to business: converting FIF to decimal feet is by far the easier of the two conversions:
>>> DECIMAL_FEET = FEET + ((INCHES + NUMERATOR/DENOMINATOR)/12).
This should not be difficult to program.

Converting decimal feet to FIF is not so trivial, but is still conceptually simple:
>>> FEET = Integer of DECIMAL_FEET
>>> INCHES = Integer of (12 * (decimal portion of DECIMAL_FEET))
>>> NUMERATOR of fraction = Integer round off of (DENOMINATOR of fraction) * (decimal portion of (12 * (fraction of DECIMAL_FEET)))

However, if you want to reduce the fraction (e.g. 12/16 becomes 3/4), it's tricky. The technique I use is basically magic! Actually, I extracted it from the PPC ROM routine FR. The PPC ROM is an amazing plug-in module for the HP-41 that was developed by the PPC users group…there's lot's of information about the PPC ROM at MoHPC and other places on the WEB. Fraction reduction is explained this way in the PPC ROM user's manual: "…the greatest common divisor routine uses the iteration formula: R[i+1]=(R[i-1])MOD(R) so that GCD=R when R[i+1]=0" Note: the brackets denote subscripts. It's been a long time since I actually went through the programming of FR, but suffice it to say it is one clever routine.

I hope, somehow, this helps you. Good luck.

Fred
 
Status
Not open for further replies.
Back
Top