Post Reply 
(50g) USER key ": division" a) decimal into (pi) fractions b) no limits
01-10-2021, 09:05 PM
Post: #18
RE: HP50G USER key ": division" a) decimal into (pi) fractions b) no limits
Thanks to John Keith and DavidM, here is a shorter version
of the assignment user key 65.1 and 65.3
(no more IF... THEN DROP END).

In bold the two changes in the two Assignment-Key-User Programs.

Decimal to fraction:
\<< RCLF \-> x f
\<< RAD x TYPE 9 \=/
IF
THEN x DUP DUP ABS 1 <
IF
THEN \->Q
ELSE \->Q DUP PROPFRAC
END
ELSE x DUP PROPFRAC DUP2 SAME DROPN
END
\->STR "+-" "-" SREPL DROP OBJ\-> f STOF
\>>
\>>
65.1 ASN

Fraction 'a/b+c/(d×e)' to decimal/reduced fraction/many digits:
\<< DUP 0 0 0 RCLF \-> x1 x2 x21 num f
\<< RAD -105 CF x1 \->STR "." "" SREPL 0 ==
IF
THEN DROP
ELSE OBJ\-> 'x2' STO x2 x1 / \->NUM LOG DUP FP 0 \=/
IF
THEN DROP "Instead of decimals (ab.c),

Try fractions
('abc/10') !" DOERR
END \->STR "." "" SREPL DROP OBJ\-> ALOG 'x21' STO
IF x21 1 >
THEN x2 x21 /
ELSE
IF x21 1 <
THEN x2 x21 INV *
ELSE x2
END
END \->STR "." "" SREPL DROP OBJ\->
END DUP EXPAND DUP2 SAME DROPN DUP \->NUM DUP 'num' STO num ABS 100000000000 > num FP 0 \=/ OR
IF
THEN OVER 10 100 ^ * PROPFRAC PROPFRAC -105 SF DUP TYPE 9 ==
IF
THEN OBJ\-> 3 DROPN
END
ELSE DROP
END f STOF
\>>
\>>
65.3 ASN

Regards,
Gil
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP50G USER key ": division" a) decimal into (pi) fractions b) no limits - Gil - 01-10-2021 09:05 PM



User(s) browsing this thread: 1 Guest(s)