Enter RPN

Update of ”Percent of Total”
Login

Update of ”Percent of Total”

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

Artifact ID: f4543f9c0b1166dde78f8b2bf9a8228a931e89119e45dda916a3af7706012695
Page Name:Percent of Total
Date: 2025-09-20 06:30:48
Original User: tangent
Mimetype:text/x-markdown
Next 80fbb5854ff49ba9ef0a57e6fd7b713d07bb8eb9906251d0c54ba1992bd564dc
Content

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:

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.