D 2025-09-20T06:30:48.715 L Percent\sof\sTotal N text/x-markdown U tangent W 2914 I am not a great fan of the HP-12C, since my interest is more in the scientific side of the calculator world, but one feature I do admire is its `%T` button. Given a total pushed onto the stack as _y_ and then a “part” as _x_, give the percentage that _x_ is of _y_. For instance, thirty is 60% of fifty: ``` 50 ENTER 30 %T 60 ``` What I don't get is how this is a “financial” calculation, specifically. It’s useful in lots of areas, but as far as I have been able to find out, HP never gave it to us on a “scientific” calculator. It may be buried somewhere in the big graphing calculators’ menus, but I didn’t go looking there. According to the HP-12c Platinum manual, Appendix E, the calculation is simple: ``` 50 ENTER 30 ÷ 1/𝑥 100 × ``` I then asked a coding AI: > Write an HP-32S program labeled "T" for computing the percentage of total given the total in stack register y and the partial value in x. It thought this was a fine solution: ``` LBL T ; 01: Label T R↓ ; 02: Roll down (total goes to X, partial to Y) ÷ ; 03: Divide partial by total 100 ; 04: Enter 100 × ; 05: Multiply by 100 for percentage RTN ; 06: Return ``` 🤦‍♂️ It has confused 1/𝑥 with roll-down, but it took my gentle correction graciously and made the proper fix. I was then able to convince it that HP calculators of this era couldn’t input 100 as a single instruction, but had to be given the digits separately, adding two instructions. It took considerably more prompting to get it to understand that it could save a program step with EEX and its implied “1” input, and I had to hand-write the program spec, but I find the result straightforward and satisfactory: ``` LBL T ; 01: percent of the total (%T) in Y, with partial value in X x<>y ; 02: swap total into X, partial into Y ÷ ; 03: get decimal form of answer EEX ; 04: input a power-of-10 value... 2 ; 05: ...with exponent 2 = 100 × ; 06: multiply to get percentage RTN ; 07: return %T in X ``` The thing is, there is an even more efficient form due to “tony(nz)” on the old HP Museum forum in post #9 of [this thread](https://www.hpmuseum.org/cgi-bin/archv017.cgi?read=113789): ``` LBL T ; 01: percent of the total (%T) in Y, with partial value in X 1/𝑥 ; 02: take reciprocal of total: 1/total (with partial in Y) % ; 03: calculate partial% of (1/total) giving ; (partial/100) × (1/total) = partial/(100×total) 1/𝑥 ; 04: flip that to give the intended calculation RTN ; 05: return %T in X ``` Step 3 is where the magic happens, and I confess to needing the AI to explain it to me before I could comment it properly. Brilliant! Eight instructions for the naïve version down to five. Z b3421de7555390a4e2056f04e3e56534