HP Forums
HP 50g Format Sexagesimal Output - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: HP 50g Format Sexagesimal Output (/thread-3719.html)



HP 50g Format Sexagesimal Output - MNH - 04-26-2015 02:59 PM

Hello,

This post is meant to correct my erroneous code posted on 06-29-2014, thread
HP 50g Surveyor's Stuff. The code does not cover all situations where there are
sixty seconds displayed, which is not allowed in sexagesimal measurement. I
would appreciate any help concerning my thought process and code.

// Format sexagesimal output
\<< 4 RND \->STR DUP
SIZE
\<< "59" SAME // check for 59 minutes
\<< STR\-> CEIL \->STR // add 1 degree
\>>
\<< STR\-> .01 + \->STR // add 1 minute
\>> IFTE
\>> \-> str size Degmin
\<<
CASE size 6 ==
THEN str 5 6
SUB "60" SAME // check for 60 seconds
\<< str 5 "00"
REPL DUP 3 4 SUB
Degmin EVAL
\>>
\<< str
\>> IFTE
END size 7 ==
THEN str 6 7
SUB "60" SAME // check for 60 seconds
\<< str 6 "00"
REPL DUP 4 5 SUB
Degmin EVAL
\>>
\<< str
\>> IFTE
END size 8 ==
THEN str 7 8
SUB "60" SAME // check for 60 seconds
\<< str 7 "00"
REPL DUP 5 6 SUB
Degmin EVAL
\>>
\<< str
\>> IFTE
END
END
\>>
\>>

checksum: # A374h
bytes: 508.5

Regards,

Mark


RE: HP 50g Format Sexagesimal Output - Marcus von Cube - 04-26-2015 03:42 PM

With [code ] tags around the listing, the text looks nicer.

(04-26-2015 02:59 PM)MNH Wrote:  Hello,

This post is meant to correct my erroneous code posted on 06-29-2014, thread
HP 50g Surveyor's Stuff. The code does not cover all situations where there are
sixty seconds displayed, which is not allowed in sexagesimal measurement. I
would appreciate any help concerning my thought process and code.

Code:
// Format sexagesimal output
\<< 4 RND \->STR DUP
SIZE
  \<< "59" SAME   // check for 59 minutes
      \<< STR\-> CEIL \->STR   // add 1 degree
      \>>
      \<< STR\-> .01 + \->STR   // add 1 minute
      \>> IFTE
  \>> \-> str size Degmin
  \<<
      CASE size 6 ==
        THEN str 5 6
SUB "60" SAME   // check for 60 seconds
        \<< str 5 "00"
REPL DUP 3 4 SUB
Degmin EVAL
        \>>
        \<< str
        \>> IFTE
      END size 7 ==
      THEN str 6 7
SUB "60" SAME   // check for 60 seconds
        \<< str 6 "00"
REPL DUP 4 5 SUB
Degmin EVAL
        \>>
        \<< str
        \>> IFTE
      END size 8 ==
      THEN str 7 8
SUB "60" SAME   // check for 60 seconds
        \<< str 7 "00"
REPL DUP 5 6 SUB
Degmin EVAL
        \>>
        \<< str
        \>> IFTE
      END
    END
  \>>
\>>

checksum: # A374h
bytes: 508.5

Regards,

Mark



RE: HP 50g Format Sexagesimal Output - MNH - 04-26-2015 05:12 PM

Thanks for your reply! Is there an FAQ that describes the use of code tags?


RE: HP 50g Format Sexagesimal Output - Marcus von Cube - 04-26-2015 07:00 PM

(04-26-2015 05:12 PM)MNH Wrote:  Is there an FAQ that describes the use of code tags?

The Help button (top right) should give you some clues.