Garth wrote:That looks excellent! Thanks, Mike! I bookmarked it.
The site was new to me too, I found it by entering few key words in a search engine (no, the other one, 4-letter-named, starts by B-, ends on -ing).
Now -- vast subject drift, absolutely nothing to do with "Buy&Sell", but an attentive content manager might find the correct rubric to file it -- within that a. m. HP Handheld Conference 2014 gleanings I found
a comparison of four solutions of the same task on different machines with different programming languages. (There are only the slides without notes, no hint about the conclusion.) Mission: for numbers A and B (
input) compute (A-B)/B and (B-A)/A and show
output as %, positive value first or 1st on stack.
The shown solution for HP41 on page four looked a bit
too long (almost 'spaghetti') to me:
- Code: Select all
01▶LBL "PCH"
02 X>Y?
03 X<>Y
04 %CH
05 X<>Y
06 LASTX
07 X<>Y
08 %CH
09 X<>Y
10 RDN
11 END
I suggest (two lines less but only one byte shorter):
- Code: Select all
01▶LBL "WTF"
02 RCL Y
03 %CH
04 RDN
05 %CH
06 R^
07 X<0?
08 X<>Y
09 END
I assume that over time I am for sure not the first who found a shorter way to achieve the goal. So this append is just for the record: I also done it.
/M.