Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!news.cs.indiana.edu!news.nd.edu!mentor.cc.purdue.edu!noose.ecn.purdue.edu!en.ecn.purdue.edu!wscott From: wscott@en.ecn.purdue.edu (Wayne H Scott) Newsgroups: comp.sys.handhelds Subject: Re: DEC2FRAC-II for the HP48SX Message-ID: <1991Mar30.191031.26274@en.ecn.purdue.edu> Date: 30 Mar 91 19:10:31 GMT References: <12222 Organization: Purdue University Engineering Computer Network Lines: 94 In article <27f2c9cd:1772.4comp.sys.handhelds;1 >Wayne Scott asks for DEC2FRAC to parse equations like ->Q does. > >No problem. I'm on it... > >-- Joe Horn -- Sorry I've already done it... This program handles: real numbers complex numbers equations TAGGED objects lists and any combination of the above { .25 '.5*X-.75' (.25, -.333) } 10 DO\->Q { '1/4' '1/2*X-3/4' '1/4-1/3*i' } I now have this programs assigned to my old \->Q key. Many thanks to: Joseph Korn for writing the DEC2FRAC program and Jan Brittenson for showing me how to handle equations. (I never knew OBJ\-> would do that) [ sorry typed in by hand } DO\->Q Checksum: # C215h Size: 386 \<< \-> A D \<< A TYPE \-> T \<< CASE T 0 == THEN A D D2F END T 9 == THEN A OBJ\-> \-> n oper \<< 1 n START D DO\->Q n ROLL NEXT oper EVAL \>> END T 1 == THEN A RE D DO\->Q A IM D DO\->Q i * + END T 5 == THEN A OBJ\-> \-> n \<< 1 n START D DO\->Q n ROLL NEXT n \->LIST \>> END T 12 == THEN A OBJ\-> SWAP D DO\->Q SWAP \->TAG END A END \>> \>> \>> D2F is the same program posted eariler with the following changes. D2F Checksum: # 2667h Size: 339 %%HP:T(3); \<< DUP2 IF 1 > SWAP FP AND THEN SWAP EVAL \-> c f @ added EVAL so it can handle '2/4' \<< 0 1 f WHILE OVER c < OVER AND REPEAT INV DUP FP 4 ROLLD IP OVER * ROT + ROT END DROP DUP2 c IF DUP2 > THEN - OVER / CEIL * - ELSE 3 DROPN END DUP2 1 2 START DUP f * 0 RND SWAP / f - ABS SWAP NEXT IF > THEN SWAP END DROP DUP f * 0 RND \>> IF OVER 0 < THEN NEG SWAP NEG ELSE SWAP END @ so -.25 -> -(1/4) not 1/-4 IF DUP ABS 1 > THEN # 5603Eh SYSEVAL ELSE DROP END ELSE DROP END \>> Joe -- Is there a better way to handle negitive fractions? -- _________________________________________________________________________ Wayne Scott | INTERNET: wscott@ecn.purdue.edu Electrical Engineering | BITNET: wscott%ecn.purdue.edu@purccvm Purdue University | UUCP: {purdue, pur-ee}!ecn.purdue.edu!wscott