Post Reply 
(50g) USER key ": division" a) decimal into (pi) fractions b) no limits
12-31-2020, 01:08 PM
Post: #6
RE: HP50G USER key ": division" a) decimal into (pi) fractions b) no limits
Conversion of fractions into decimals (many digits)

I somewhat changed the beginning of the code, in order to the program accept expressions like
'57/3/19*727/31' or '59/3/19*727/31'
and simplify them before when possible.

'57/3/19*727/31'
+ programme returns 4 stacks levels:
'57/3/19*727/31' (original stack expression )
'729/31' (simplified expression)
23.45... (decimal value approximation)
2345... (many digits)

'59/3/19*727/31'
+ programme returns 4 stacks levels:
'59/3/19*727/31' (original stack expression )
'42893/1767' (simplified expression)
24. 274... (decimal value approximation)
242744765139... (many digits)

Meanwhile '727/31'
+ programme returns only 3 stacks levels:
'727/31' (original, already simplified stack expression )
23.45... (decimal value approximation)
2345... (many digits)

Here are the full codes (in bold, the changes).

\<< RCLF \-> f
\<< -105 CF DUPDUP EXPAND DUP ROT SAME
IF
THEN DROP
END
DUPDUP \->NUM SWAP \->STR DUP SIZE \-> x s //I suppressed here the flag Var f already introduced right at the beginning of the program
\<< RAD 2 s 1 -
START x "." POS DUP x 1 ROT 1 - SUB x ROT 1 + s SUB + 'x' STO
NEXT x OBJ\-> 100 ALOG * PROPFRAC PROPFRAC -105 SF DUP TYPE 9 ==
IF
THEN OBJ\-> 3 DROPN
END f STOF
\>>
\>>
\>>

Note
Important: the program to be able to work has to be written with integers (without dots),
like "-105 CF", "9 TYPE", "100 ALOG", asf
(and not with dots like "-105. CF", "9. TYPE", "100. ALOG", asf).

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 - 12-31-2020 01:08 PM



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