Author Topic: CASIO-like ENG key for HP 50g  (Read 2126 times)

0 Members and 1 Guest are viewing this topic.

Offline supergems

  • LV2 Member (Next: 40)
  • **
  • Posts: 38
  • Rating: +1/-14
    • View Profile
CASIO-like ENG key for HP 50g
« on: June 06, 2016, 08:50:42 am »
Thnaks to John H Meyers for these marvel programs https://groups.google.com/forum/#!topic/comp.sys.hp48/Ud03tImdu-w:

Code: [Select]
%%HP: T(3)A(R)F(.); @ HP49 ONLY! - downloadable file (use Kermit)

@ Programs ENG-> and ENG<- accept REAL numbers (no units),
@ changing the exponent by 3 each time (displaying as a string);
@ use NORM to change string back to the original real number:

\<< { * - } ENGX \>> 'ENG\->' STO

\<< { / + } ENGX \>> 'ENG\<-' STO

\<< STR\-> \>> 'NORM' STO

@ Subroutine (not for direct use):
\<< LIST\-> DROP RCLF \-> a b f \<<
  { { 514. DOERR } { 3. EXP ENG \->STR { DROP DROP } ENGX }
  { DUP "E" POS DUP2 1. + OVER SIZE SUB UNROT 1. - 1. SWAP SUB
  DUP STR\-> 3. ALOG a EVAL STD \->STR DUP "E" POS { DROP SWAP }
  { SWAP DROP SWAP STR\-> 3. b EVAL \->STR
  1. OVER SIZE 1. - SUB } IFTE "E" SWAP + + } } { 0. 2. }
  3. PICK TYPE POS 1. + GET EVAL f STOF  \>> \>> 'ENGX' STO


@ Programs U-> and U<- accept UNIT objects only,
@ transforming them to other equivalents
@ using different unit prefixes, e.g.  123.4_m = .1234_km

\<< 0. UU \>> 'U\->' STO

\<< 1. UU \>> 'U\<-' STO

@ Subroutine (not for direct use):
\<< \<<
  "yzafpn\Gmm.kMGTPEZYYc.d.Dkhk"
  "YZEPTGMk.m\Gmnpfazyyh.D.dmcm"
  IFTE DUP ROT POS 1. + DUP SUB \>> \-> d p
  \<< DUP TYPE 13. \=/ { 514. DOERR } IFT DUP
  :INNERCOMP: #54AFh SYSEVAL :{}N: #5459h SYSEVAL
  DUP 2. GET "1" SAME 3. 2. IFTE DUP2 GET
  IF DUP TYPE 24. == THEN :CHR>$: #37AA5h SYSEVAL d p EVAL NUM
  IF DUP 46. \=/ THEN :COERCE: #262F1h SYSEVAL
  :#>CHR: #5A75h SYSEVAL 1. \->LIST REPL
  ELSE DROP DUP2 1. SWAP 1. - SUB UNROT DUP2 1. + GET
  UNROT 3. + OVER SIZE SUB + + END
  ELSE UNROT DUP2 1. SWAP 1. - SUB UNROT 1. + OVER SIZE SUB
  ROT "." d p EVAL NUM :COERCE: #262F1h SYSEVAL
  :#>CHR: #5A75h SYSEVAL SWAP :umP: #2D76Dh SYSEVAL 3. \->LIST
  SWAP + +  END :INNERCOMP: #54AFh SYSEVAL
  :EXTN: #5481h SYSEVAL CONVERT \>> \>> 'UU' STO

{ ENG\-> ENG\<- NORM ENGX U\-> U\<- UU } ORDER

@ End of HP49 downloadable file (EVALuate it to install programs)

examples
Code: [Select]
0.01 'ENG\->' 10.E-3 'ENG\->' 10000.E-6 'ENG\->' 10000000.E-9 'ENG\->' 10000000000.E-12
0.01 'ENG\<-' 10.E-3 'ENG\<-' .01E0 'ENG\<-' .00001E3 'ENG\<-' .00000001E6 'ENG\<-' .00000000001E9
5000.E-3 'NORM' --> 5.

examples with units
Code: [Select]
'1_m' 'U\->' '1000._mm' 'U\->' '1000000._\Gmm' ('\Gm' = 'μ')
'1_m' 'U\<-' '.001_km' 'U\<-' '.000001_Mm'