HP Forums
(35S) Reverse Digits Programme - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (35S) Reverse Digits Programme (/thread-3817.html)



(35S) Reverse Digits Programme - Gerald H - 05-12-2015 05:00 PM

The programme REVERSO takes integer input & returns the digit reversed integer.

eg Input 123 returns 321.

1 LBL R
2 0
3 x<>y
4 x=0?
5 GTO R009
6 10*REGY+RMDR(REGX,10)
7 IDIV(REGY,10)
8 GTO R004
9 R↓
10 RTN


RE: HP 35S: Reverse Digits Programme - Gerald H - 05-19-2015 07:25 AM

A slight optimization of REVERSO, one line smaller & faster for entry > 0, slower for 0. Why bother to optimize? speed difference is negligible, 35S has more than enough memory...it's just that I feel an irritation when I see the waste looking up at me from the page.

1 LBL R
2 0
3 x<>y
4 10*REGY+RMDR(REGX,10)
5 IDIV(REGY,10)
6 x≠0?
7 GTO R004
8 R↓
9 RTN