Post Reply 
RPL second impressions (HP 28)
06-27-2018, 03:08 AM
Post: #4
RE: RPL second impressions (HP 28)
(06-27-2018 01:19 AM)mdunn Wrote:  Algebraic:
IF 'FP(a/b)==0' EVAL THEN ... END
THAT one took a while to figure out!

Other (better?) ways?

A few thoughts:

- Take a look at the documentation for the IFT and IFTE commands if you really want to stick with a "load the stack first before finalizing the test" approach. There are some slight footprint and speed advantages to using those commands in certain situations, but you sacrifice some readability (IMHO) if you go that route. It's a nice option to have, though.

- This applies to 48-50 RPL systems, but I'm not sure about the 28: the backquote character (`) can be used to encapsulate a clause that is automatically evaluated instead of manually evaluating it with EVAL. So in this case, you could use `FP(a/b)==0` instead of 'FP(a/b)==0' EVAL.

- RPL statements that expect a boolean truth value automatically treat 0 as FALSE and any other value (positive or negative) as TRUE. This can be an advantage for size and speed in some situations. NOT can be applied to any number, which will convert 0 to 1 (TRUE), and any non-zero number to 0 (FALSE). So in this case, you could actually use a b / FP NOT in a non-algebraic clause to perform the truth test. It may or may not be as readable, but it saves space and time. Again, you get to decide which is more important.

Finally, as Carsen says, experiment. Trying out various language features is the best way to learn, IMHO.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RPL second impressions (HP 28) - mdunn - 06-27-2018, 01:19 AM
RE: RPL second impressions (HP 28) - DavidM - 06-27-2018 03:08 AM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018, 01:58 PM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018, 04:06 PM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018, 05:11 PM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018, 07:45 PM
RE: RPL second impressions (HP 28) - mdunn - 06-28-2018, 08:48 PM
RE: RPL second impressions (HP 28) - ttw - 07-04-2018, 10:52 PM



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