From: Norm Arnold <Norm_Arnold@bc.sympatico.ca>
Newsgroups: comp.sys.hp48
Subject: Re: Feet/inches/fractions arithmetic program?
Date: Thu, 26 Feb 1998 18:08:28 -0800
Organization: Norm's Drafting Ltd.
Lines: 180
Message-ID: <34F6201B.C4D068B9@bc.sympatico.ca>
References: <34f5b3a0.17931209@news.hal-pc.org>
Reply-To: Norm_Arnold@bc.sympatico.ca
NNTP-Posting-Host: srry01m02-81.bctel.ca
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 4.04 [en] (Win95; U)
Xref: republic.btigate.com comp.sys.hp48:7270

John Dawson wrote:

> Is there a program for the HP48gx to easily enter dimensions in feet,
> inches and fractions and performing basic arithmetic (+,-,*,/) with
> them?  If so, where?  Thanks.

  Before you can work in FIS (feet, inches and sixteenths) you have to be
able to convert to and from it.  Here in Canada we also use metric
(millimeters).  The following programs do all my conversions.  F stands
for decimal feet, M for metric and S for FIS.

F2M:
\<< 304.8 * \>>
F2S:
\<< 4 FIX DUP IP SWAP FP 12 * DUP IP SWAP FP .16 * + 100 / + \>>
M2F:
\<< 304.8 / \>>
M2S:
\<< M2F F2S \>>
S2F:
\<< DUP IP SWAP FP 100 * DUP IP SWAP FP .16 / + 12 / + \>>
S2M:
\<< S2F F2M \>>

   Now you can use them to work in FIS.  The following six programs may
be useful to you.  SADD takes two FIS numbers from the stack and leaves
the sum in FIS.  SSUB takes two FIS numbers from the stack and leaves the
difference in FIS. SMUL requires an FIS number in level 2 and a real
number in level 1 and leaves the sum in level 1 in FIS. SDIV requires an
FIS number in level 2 and a real number in level 1 and leaves the
quotient in level 1 in FIS. STKADD will add all the numbers on the stack
and leave the total on the stack. If user flag 1 is set then all
additions will be done with SADD, if user flag 1 is not set then the
normal add routine will be used. STKSUB will add all the numbers on the
stack except the top one, then subtract that sum from the top one and
leave the difference on the stack. If user flag 1 is set then all
additions and the subtraction will be done with SADD and SSUB, if user
flag 1 is not set then the normal add and subtract routines will be used.

SADD:
\<< S2F SWAP S2F + F2S \>>
SSUB:
\<< S2F SWAP S2F SWAP - F2S \>>
SMUL:
\<< SWAP S2F * F2S \>>
SDIV:
\<< SWAP S2F SWAP / F2S \>>
STKADD:
\<<
  WHILE DEPTH 1 >
  REPEAT
    IF 1 FS?
    THEN SADD
    ELSE +
    END
  END "Total" \->TAG
\>>
STKSUB:
\<<
  WHILE DEPTH 2 >
  REPEAT
    IF 1 FS?
    THEN SADD
    ELSE +
    END
  END
  IF 1 FS?
  THEN SSUB
  ELSE -
  END "Diff" \->TAG
\>>

   Now you can use these programs in other programs such as TRI.  This
program will calculate any right angled triangle in either metric or
imperial depending on user flag 1.  It will also check user flag 2 and if
set the output will be sent to the IR port for the HP82240B printer.  In
any case all answers are stored in variables for future use.

TRI:
  \<<
"Triangulations:" {
{ "Rise:" } {
"Base:" } { "Hyp: "
} { "Angle:" } } {
1 } { R B H A } { 0
0 0 0 } INFORM
          IF
          THEN EVAL
          ELSE KILL
          END
          IF 1 FS?
          THEN 4
ROLL S2F 4 ROLL S2F
4 ROLL S2F 4 ROLL
          END 'A'
STO 'H' STO 'B' STO
'R' STO
          IF R B
AND
          THEN
"R & B" R B / ATAN
'A' STO R SQ B SQ +
\v/ 'H' STO
          ELSE
            IF R A AND
            THEN
"R & A" R A TAN /
'B' STO R A SIN /
'H' STO
            ELSE
              IF R H AND
              THEN
"R & H" R H / ASIN
'A' STO H SQ R SQ -
\v/ 'B' STO
              ELSE
IF B A AND
THEN "B & A" B A
TAN * 'R' STO B A
COS / 'H' STO
ELSE
  IF B H AND
  THEN "B & H" B H
/ ACOS 'A' STO H SQ
B SQ - \v/ 'R' STO
  ELSE
    IF A H AND
    THEN "A & H" H
A SIN * 'R' STO H A
COS * 'B' STO
    ELSE
"Bad Input" KILL
    END
  END
END
              END
            END
          END
          IF 1 FS?
          THEN R
F2S 'R' STO B F2S
'B' STO H F2S 'H'
STO
          END CLLCD
"INPUT = " SWAP + 1
DISP R "RISE " \->TAG
2 DISP B "BASE "
\->TAG 3 DISP H
"HYP  " \->TAG 4 DISP
A "ANGLE" \->TAG 5
DISP A TAN
          IF 1 FS?
          THEN F2S
          ELSE 250
*
          END
"BEVEL" \->TAG 6 DISP
          IF 2 FS?
          THEN
# 320207d SYSEVAL
PRLCD
          END 3
FREEZE
        \>>

   If you are interested in this type of thing I have other programs that
may be of interest to you. This include such gems as Oblique triangle
solutions, Segmental functions, Hip angles and Parabolic cambers. I am a
steel detailer and have many programs that apply to my field and I am
developing more all the time. If you are interested e-mail me.
  Good luck whatever you are doing.
   ---------------------------------------------------------
   Norm_Arnold@bc.sympatico.ca    "If you think you can,
                                   you can. And if you think
         Norm Arnold               you can't, you're right."
    Surrey, British Columbia
           Canada                  - Mary Kay Ash
   ---------------------------------------------------------

