In case anyone wants a diversion from the Prime discussion, I had one final thought about the HHC 2013 RPN Programming Challenge that I’ve been meaning to bring up. (I’m probably the only person who spent much time on the challenge after about September 25, but I enjoy them and so tend to keep fiddling with them long after the conference.) I don’t have any new programming revelations or insights beyond what the group presented in the few days after conference, just this: I believe all of the solutions presented at the forum (except Pauli’s here) converted the octal value one digit at a time, from left to right. At some point, I began to wonder if it would be more accurate to convert the number from right to left, i.e., start with least significant digit. It seemed to me that conversion from right to left would more accurately get the carry correct from the far right digits. Perhaps that is not a real concern, but I decided to attempt to write a program to do so, probably just for the fun of it. While I was able to write a 15 step wp34s program to convert from left to right, the best I have done so far for right-to-left conversion is 27 steps, as follows:

Step Command Comment

001 ENTER duplicate entered value

002 EXPT extract exponent

003 +/- change sign of exponent

004 #011 enter 11

005 + add 11 to exponent

006 #008 enter 8

007 x<>Y swap

008 y^x calculate multiple of 8 for least significant digit

009 x<>Y swap

010 MANT extract mantissa of N

011 SDL 10 multiply by 1E10

012 #000 enter 0 for initial converted value

013 <>YYZX get stack in right order

014 FRAC take fractional part (only one digit)

015 STO-Y subtract from original to get integer part in Y

016 SDL 01 multiply fractional part by 10

017 RCL/ Z divide by current power of 8

018 STO+ T add to current sum

019 CL x Clear X, disable stack lift

020 #008 enter 8

021 STO/ Z divide into current power of 8 for next power

022 Rdown roll down

023 SDR 01 divide by 10

024 ENTER duplicate N

025 x=/=0? check if done

026 BACK 012 loop back until done

027 RCL T done, recall converted value

The above is for a 12-digit entry, since that’s the most you can enter on a wp34s. If you enter a value with less than 12 digits, it dutifully converts the trailing zeroes. Although I did not intend this result, this program seems to work for any value that can be entered into a wp34s, i.e., is not limited to 0 <= n <= 1. It does of course assume a valid octal input, i.e. no 8s or 9s.

I note that this program does produce what Pauli declares to be the “True” answer for an input of 1e-95, so perhaps it is more accurate?