I hate doing things I can make my computer do for me. My adventures in customizing and automating computers. Primarily with AutoCAD and Microsoft Office.

Wednesday, May 03, 2006

Feet and inches with HP calculators

In the early 1980's I was introduced to the HP 41C programable calculator and was introduced to a series of small programs that perform basic math functions on imperial measurements without having to convert to decimal. To do this, distances are represented by what I will refer to as HPFeet, thus: FF.IISS where FF = whole feet, II = whole inches, and SS = sixteenths of an inch. In this format, 12'-1 1/2" is represented as 12.0108. The basic math functions, as I now use in an HP 48GII follow.

FTD: Feet to Decimal - Converts FF.IISS to decimal feet. For example, 12.0108 (which represents 12'-1 1/2") becomes 12.125
DUP IP SWAP FP 100 * DUP IP 12 / ROT + SWAP FP 100 * 16 / 12 / +

DTF: Decimal to feet - Converts decimal feet and inches in my HPFeet.
DUP IP SWAP FP 12 * DUP IP SWAP FP 16 * 100 / + 100 / +

FADD: With HPFeet numbers in both the first and second stack positions, the following will add them together leaving the result in the first stack position as HPFeet.
FTD SWAP FTD + DTF

FMIN: With HPFeet numbers in both the first and second stack positions, the following will subtract the first from the second, leaving the result in the first stack position as HPFeet.
FTD NEG SWAP FTD + DTF

FMULT: With an HPFeet number in both the second stack position and a decimal number in the first stack position, the following will multiply them, leaving the result in the first stack position as HPFeet.
SWAP FTD * DTF

FDIV: With an HPFeet number in both the second stack position and a decimal number in the first stack position, the following will divide the second by the first, leaving the result in the first stack position as HPFeet.
INV SWAP FTD * DTF

Later, I will include a couple more functions along with key assignments that simplify the use of the above routines.

No comments: