The 20s is apparently faster than the 32sii


I wrote a small program for calculating prime factors of a given number, based loosely on the one found here:

For kicks, I made a version for both the 32sii, and the 20s. Despite the 20s being algebraic, there was actually very little that needed to be adapted for this particular program. Both are available here:

For both programs, enter a positive integer, then XEQ F. Execution pauses when a factor is found. Press R/S to find the next factor. When 0 is displayed, there are no more factors.

Interestingly enough, the 20s seems to produce results noticeably faster. Using the input 869,103,111, the 32sii finds the last factor (4,561) in about 1:20 total. The 20s takes just under 1:00.

Anybody have an original 32s lying around and care to see how it clocks in? I'm assuming a 21s will have the same speed as a 20s.


Dave --

My HP-32S (1990 model with recessed display) takes 56 seconds to obtain all four factors.

Since it lacks the "<=" and ">=" tests, a small workaround was necessary:

   32SII:             32S:

Z24 x<=y? Z24 x>y?
Z29 CLx V03 STO F
V05 CLx

Here are my checksums on the HP-32S, which are not the same as those on the HP-32SII for the same instructions:

LBL F   714D   10.5
LBL Y 0116 19.5
LBL Z E93C 39.0
LBL V 721A 9.0
LBL W 63E1 15.0
LBL X 5878 15.0

Between two models having the same microprocessor, why does the more-advanced one tend to run somewhat slower? For example, it has also been claimed that the HP-11C is marginally faster than the HP-15C. I speculate that the lengthier microcode of the more-advanced models causes machine-level instructions to take a bit longer to be found from op-codes. However, more-knowledgeable folks might have a better answer.


Thinking about this a bit more, I'd assume that the ROM contents include some kind of index -- an address lookup table that points to where the instructions for a given op-code reside in ROM. That would speed things up, but access is probably still a bit slowed by larger ROM contents.

Another factor is overloading of operations. Consider the HP-11C versus the HP-15C:

On the HP-11C, "*" only multiplies two real-valued scalars.

On the HP-15C, "*" can multiply two real-valued scalars, two complex-valued scalars, two matrices, or a real scalar and a matrix. Under the microcode for "*" (hex op-code FC), conditional tests for the types of both arguments and status of flag 8 must be performed before the multiplication is done.

Regarding the HP-32S and HP-32SII, the display and memory management are almost the same. The difference in functionality is mostly the HP-32SII's equations and fractions -- not nearly as substantial as the difference between the HP-11C and the HP-15C. Thus, the difference in execution time between 76-80 seconds (HP-32SII) and 56 seconds (HP-32S) is surprising to me. I had 207 bytes of other programming in the HP-32S at the time of the test, so I can't necessarily credit fast GOTO's.

-- KS

Edited: 4 Jan 2010, 1:12 a.m. after one or more responses were posted


Between two models having the same microprocessor, why does the more-advanced one tend to run somewhat slower? For example, it has also been claimed that the HP-11C is marginally faster than the HP-15C. I speculate that the lengthier microcode of the more-advanced models causes machine-level instructions to take a bit longer to be found from op-codes. However, more-knowledgeable folks might have a better answer.

-- KS

It's actually not a huge surprise, since the two machines - according to Wikipedia, at least - both run a 640 KHz CPU. The 32sii has a more complicated display system and memory management, plus more opcodes as you mentioned. That translates to more overhead to lug around - overhead which is evidently more expensive than managing the AOS input of the 20s.

I was under the impression that the segmented-display Pioneers had a slower CPU than the dot-matrix ones, which is why I initially found the results unexpected. But given the hardware details, things seem to fall into place.

And a similar algorithm on my 48GX executes in under half a minute, despite the machine "feeling" slower than the Pioneers. Must be just an illusion caused by the overhead of drawing to that huge bitmapped display!


Instead of Wiccanpedia, you can always check Craig Finseth's site:

Edited: 3 Jan 2010, 9:53 a.m.


Yeah, normally I'd check there, but it seems like his site's been acting up a bit lately. Anybody else having trouble connecting, or is it just me?


I'm curious, Bill, is your reference meant to disparage Wikipedia, or just a humorous intentional misstatement?

It is a serious question, since I myself am not sure what to make of Wikipedia.


While I may use Wikipedia myself for a few things, I do not like to recommend it to students. It is true I have never seen any scientific or mathematical pages incorrect... though there may have been some incomplete ones... this is not true for other subjects. Until someone has the ability, or more properly, the maturity, to judge the correctly the content, one should be circumspect in recommending Wikipedia.

Besides, it is an open system, allowing for frequent modification. Except maybe for the Ten Commandments and Boltzmann's original formulation of the second law of thermodynamics, nothing is set in stone... but electronic ether flux is too far toward the other extreme.

I am personally careful about anything I see in Wikipedia. This extends even to scientific and technical pages.


That's kind of my sentiment as well. There's a good body of knowledge there, but it should be treated as a starting point before branching out to more reputable sources. I refer to it a lot, but I've never once used it as a source for an academic paper. I have done some minor article writing and editing, though.


Hi Dave,

I would make the following small comment regarding Wikipedia:

There's a good body of knowledge there

changes to:

There's a good body of information there, knowledge requires understanding and human insight. Wikipedia is full of information, the veracity of which is by the definition of Wikipedia always open to question to a greater degree than is the case with reputable sources.

Or to put it another way: if you need to calculate the strength of something that life depends on, do you go to Wikipedia, or Timoshenko?

Edited: 3 Jan 2010, 7:46 p.m.


Except maybe for the Ten Commandments ... nothing is set in stone

Good thing you said "maybe" there. The Ten Commandments are more commonly set in type these days, a process which is prone to human fallibility. Witness the "Wicked Bible" or "Adulterous Bible", a 1631 reprint of the King James Bible, which included the memorable injunction:

Thou shalt commit adultery.

Oops. (See for the full story.)


--- Les



It would appear that this version is the one taken to heart these days.


Dave, thanks for posting this. I don't have a 32S, but I wanted to see how my 35S would perform. Your program found all factors in 1:17 on my 32sii, and in 1:27 on my 35S.

On the 32Sii, it ran in 1:16 if I started the program with R/S instead of with XEQ F.


Yeah, it's good to get back on topic.

I have both the 20S and the 32SII. Maybe I should try timing them, too, though I've never ever tried to program my 20S.

But I have tried some simple addition algorithm that's supposed to lead to convergence on the 32SII, 33S, 35S, and 50g. Yeah, the 32SII is the slowest, and the 33S is surprisingly fast, though significantly slower than the 50g (why did I even bother testing against this one??). I did not make it a scientific test; I started the program and went off somewhere, checking them only intermittently, so I have no absolute numbers, but what the 50g may take about an hour will take very many hours on the smaller calculators, especially the 32SII.


Not bad huh?

Was not using a 50g, no C programming.

Sound interesting?


Okay, I'll bite. How did you do it, Gene?



The truth is out there. Either no one is looking or no one has found it yet. Soon as someone does, I'll talk.

The old PPC Journal had a 10 digit prime number "worst case" test they used. The number was 9,999,999,967, the largest 10 digit prime, I believe.

What did this in 4 seconds determines this to be prime in less than 50 seconds.

Edited: 8 Jan 2010, 11:19 a.m.


Perhaps the truth is here?



but then... :-)


Ok, that's good news, though a scientific calc with similar features would have been even better. But one could bring forward the argument that after all financial people caused the world economic crisis, not scientists, thus financial people need a proper calc more urgently.

I want to repeat a question I asked here weeks earlier, but didn't get an answer then: Does the 30b feature the same interface the 20b does, allowing some customization?

Since you mentioned the improved keyboard in the linked articles, one could think of mating a 30b keyboard with 20b electronics else.

(Edited to include the link.)

Edited: 9 Jan 2010, 4:28 p.m. after one or more responses were posted


Yes. Same interface. No need to mate a 30b keyboard with 20b electronics. Just use a 30b.

Prime factor routine factors 9,999,999,967 as prime in a bit over 50 seconds. Try that with the 32s, 32s2, or even the 35s.

Not bad for a business calculator.

P.S. I assume HP made a business calculator because more people buy them. So, let's say 12 man months of effort to sell tons of calculators or for something much much smaller. Easy choice, but I'm guessing.


I guess I can admit now that my 20b repurposing proposal was really intended as a 30b repurposing proposal. I had considered concepts for the 20b, but with its relatively poor keyboard, it did not seem worth the trouble. With its metal-dome keyboard, the 30b would be a worthwhile candidate, I think.


How long does the 20s, 35s take on that?

I'm surprised so far such a small amount of interest. ;-)

Business machine, yes. RPN programmable with many scientific functions? yes.


I'm at 33 Minutes and counting on a 35s


I had to step away, it was done when I got back.
Time is something less than 51 minutes on the 35s


So, the new model is maybe 70-80 times faster.

Interesting. ;-)


For sure the 30b will approach good ol' HP quality better than the 20b does. If we extrapolate this series of 2 (a bit keen ;) I admit), then we'd get a model with this keyboard and a better, i.e. more versatile display next. Already the 30b, however, shall be sufficient to demonstrate successfully where repurposing may lead us to.

Ceterum censeo: HP, launch a 43S (you still have the chance to be the first).



Does anyone know (and can they say) anything about the reason for the 30b's speed improvements? Faster processor? Native (i.e., not Saturn) code?

I'm hoping, and assuming, that HP is porting their Saturn assembly code to ARM so they can get rid of the Saturnator emulator. That would greatly speed up the calculators. A 32-bit address space would simplify them greatly and allow for much more memory too.



Yes people could talk about the 30b, it has been announced. It is running native code also. No emulation.

I'm actually pretty sure the 4 second time would be cut in half if it wasn't being dropped down from 30MHz to 15MHz. Somewhere in there is a trigger to drop speed to save power when a program is taking a long time. I haven't checked to see what that threshold is.

The math library in the 20/30b isn't so much "ported" (which I will interpret here as rewriting it from one system to another) but rather was remade in platform independent C using the original math library as a base.

You wouldn't want to attempt to recreate all the saturn code in something like a 50g in C or ARM either. There are a lot of things that are very much keyed to the old processor, and frankly, there are better ways to do things in a lot of ways. Those systems were generally limited by technology and memory in a way modern systems aren't. It is much more important to have platform independence and maintainability than saving a few nibbles here or there.



30b review at ... join and get Datafile!

This review lays out the differences and improvements to the 30b compared to the 20b.

There will (eventually) be 40 learning modules online, 6 of which are dedicated to programming.

So, read the review and ask questions.


Here is the program that now determines 9,999,999,967 to be prime in about 40 seconds. Must be run in RPN mode, of course.

Byte count: 141 bytes (1/2 of total available)
Checksum: 232

Usage: Enter program catalog by pressing shift Prgm. With this program selected / displayed, key number to factor and press = =. (Yes, that's twice). Displays running while checking factors. If number is prime, displays "Prime" and shows original number. If a factor is found, displays the factor. Press R/S to continue displaying factors. Zero is displayed when all factors have been found.

Sadly, this is faster than the prime factor program that will be in the learning modules. Of course, it is much newer than that one.

FYI...This is not my code.

goto 06
lbl 02
rcl + 3
sto 3
rcl 1
= // performs a FP instruction
gf 03 // goto if false i.e. 0
lbl 00
call02 // subroutine call. 4 levels available.
rcl 1
gt 01 // goto if true i.e. non-zero
on // if non zero, this clears to zero
stop // This is equivalent to KILL on the RPL machines.
lbl 01
rcl 2
rcl 3
?>= // note: this compares rcl 2 >= rcl 3. RPL conditional order
gt 00
rcl 1
sto 3
stop // This is not R/S but KILL
lbl 03
rcl 1
rcl / 3
sto 1
= // performs an IP instruction
sto 2
rcl 4
rcl 3
?=/= // rcl 4 not equal to rcl 3 ?
gt 05 // if non-zero i.e. true go to 05.
msg Prime // displays word Prime on level 2 of display.
lbl 05
goto 02
lbl 06
sto 1
sto 4
= // performs IP instruction
sto 2
sto 3
rcl 1
gt 00 // if non-zero, go back. If LN is = zero, value was 1

Edited: 11 Jan 2010, 1:48 p.m. after one or more responses were posted


I didn't write this either, but will just mention a few things that might make it more understandable to those of us who haven't programmed on a 30b yet.

- There are no line numbers in the editor but there is a checksum and byte count (Gene you should include that.)

- This is a keystroke macro language not a typical RPN language so to get the IP fucntion on the Math menu, for example, you'd press: Math, Up, Up, =. The = essentially means to execute that function and put the result in the X register.

- Comparison functions like, ?>=, push a 1 if true on to the stack or a 0 if false. Almost always these are followed by a GT or GF function, Go-if-True or Go-if-False. These functions pop the stack and branch if the value is non-zero or zero, respectively.

- Label searches start at the beginning of memory. If you have a lot of code prior to the branch target this will substantially increase execution time for programs that do a lot of looping. To minimize this the code starting at Lbl 02, in this example, has been put at the beginning of memory and that's why you see the funky goto 06 at the top of the code, it branches to the start of the main code.

- you see "on" in a couple of places in the code, this is a CLx. The shared button reads ON/CE.



There is a line/step counter in the editor. It is in the exponential area.



There is indeed but since it's not on the left margin, program listings typed in by users typically do not show the line number.


Edited: 11 Jan 2010, 2:02 p.m.


Ah. Got it. Makes more sense now. :-)



I didn't write this code either! Actually, that honor goes to Dave Britten at the beginning of this thread, who adapted his code from the original code on the HP-67 math pak. From Dave's code, Tim Wessman wrote this code for the 30b, which I then modified (at Katie's suggestion) to move the most used subroutines to the top of the code so it would execute faster on the 30b. Whew.

Here is a hand-written annotation of the algorithm, before I rearranged the order of subroutines to make it run faster. The version that Gene listed above in this thread finds the primality of 9,999,999,967 in 40 seconds on the 30b. The annotated one in my link takes about 54 seconds.

I also wrote a version that eliminates all multiples of 7 from the pool of potential factors, but that did not reduce the execution time on the 30b, unfortunately, because most multiples of 7 are also multiples of either 2 or 3 or 5, which are already excluded.

Edited: 11 Jan 2010, 2:55 p.m.



you wrote:

So, read the review and ask questions.

Well, I take this invitation d;-). I found in your review:
The mode menu settings can now be stored and recalled by pressing store or recall and then <SHIFT><MODE>. This key sequence brings up a 12 digit number with each position corresponding to a mode menu item and its setting. ... This is described and a table of these values shown in the Programming Reference learning module.

Where is this information about mode storing and recalling available already? I'd be very interested d:-)

TIA for your help.


Walter, here is the lowdown on the mode settings. When you RCL Mode, you get a 12-digit number. Lets call it: abc,def,ghi,jkl.

  • a = 1 for Standard TVM mode, 2 for Canadian TVM mode
  • b = 1 for Semi-annual mode, 2 for Annual mode
  • c = 1 for Actual day count mode, 2 for 360 day count mode
  • d = 1 for thousands separators not visible, 2 are visible
  • e = 1 for decimal separator ., 2 for decimal separator ,
  • f = 1 for mm.ddyyyy mode, 2 for dd.mmyyyy mode
  • g = regression type, 1-7 for: ax+b, a*ln(x)+b, b*e^(ax), b*x^a, b*a^x, a/x+b, and ax^2+bx+c
  • h = 1 for 2 variable stats, 2 for 1 variable stats, 3 for 1 variable frequency
  • i = 1 for radian mode, 2 for degree mode
  • j = 1 for Chain mode, 2 for Algebraic mode, 3 for RPN
  • kl = Fix setting, 00-11, 13=Fix -1


Good job, Don! :-) Walter, ask anything you like about the 30b. More...more!

Note on the MODE stuff.

As the review says (or tries to say), you don't have to key the entire 12 digits to change a setting and a value that is outside the valid range is ignored.

So, 302 shift sto shift mode will change to fix 2 and RPN mode.

114 shift sto shift mode would change to chain mode and leave the display setting unchanged since 14 is an invalid value.

And, yes, I too want an unshifted store key.


Good job, Don! :-) Walter, ask anything you like about the 30b. More...more!
May I ask also? :^)

- Is the bottom half of the case beveled the way the 20b is?

- How flexible is this Canadian Mortgage mode? Say, can I specify monthly payments with annual compounding? Does it mean the first payment gets full interest, the last one 1/12 of the interest when in Begin mode?


The external case / shape is the same.

Canadian mortgage mode allows you to specify a value for P/YR and a value for C/YR. These can be set to a combination of any valid individual values.

I don't know exactly how amortizing a Canadian mortgage works, but the computations work and match what I expect.

From the PPC ROM manual description of FI routine:

Canadian Mortgage: Find the monthly end-of-period payment necessary to fully amortize a 25 year, $85,000 loan at 11% compounded semiannually.

Steps on the 30b:

Shift MODE up. INPUT. .... Changes to TVM Canada
Shift P/YR ... displays P/YR of 12
Down...displays C/YR default of 12.
2 INPUT...changes C/YR to 2.
300 N
11 I/YR
85000 PV
0 FV

Displays -818.15.

Full precision is -818.149794116

Agrees with PPC ROM. ;-) And, yes, I really do check HP financial calculations against the 12c first :-) and then the PPC ROM FI routine. Too much trouble pulling out my HP 92.

Edited: 14 Jan 2010, 12:10 p.m.



Internally, all calcualtions are done using a per period interest rate.

in normal mode, the per period interest rate is calculated by dividing the rate by the number of periods.

in canadian mode, the periodic interest rate is calculated using the following formula:
I=(i/c/100+1)^(c/p)-1 (actually, to be more precise: exp-1((c/p)*lnp1(i/c/100)) but who cares...)

therefore, you can have any valid combinaison of ppyr and cpyr...

after that, it's TVM as usuall...

regards, cyrille


Thanks Gene and Cyrille for enlighten me about Canadian Mortgage. I got that conpect apparently wrong :-/.


You wrote:

There will (eventually) be 40 learning modules online, 6 of which are dedicated to programming.

I ask: When?


I don't know, but of course, the 30b isn't for sale yet, so ...

Edited: 15 Jan 2010, 9:52 a.m.


I don't have a 32sii, but in this thead I noted that the 20S was faster than the 35s, for that particular implementation. I quite like the 20S, it was a nice machine for it's price/size, and the 99 merged program steps is about right to briefly implement repetative or iterative formulas. There seems to be nothing like it on the market today. For programability it's either a 35s or an overkill graphics calculator. (The Sharp EL-5250 is the only other non-graphics programmable that I know of, but is not available in much of Europe).


Casio has some programmables of which the fx-4500pa is an evergreen for good reasons. Not a bad calculator if you don't mind the entry system and hard to read keyboard legends.


Thanks, doing some more research I found Casio have more programmable models. the FX-50F+ which I've found on UK online stores and the FX-5800P which is not available in the UK, but in Germany and Switzerland for about the same price as a 35s (on the plus side it does seem to have connectivity options).

Edited: 5 Jan 2010, 10:04 a.m.


I have a fx-5800P in front of me. The connectivity is only between identical machines. The cable is a standard Casio connectivity cable but that does not mean that you can mix and match devices.

Still better than no connectivity at all.


Oh, I thought it might connect to a PC using a special cable like the 9850g. Too bad.

Possibly Related Threads…
Thread Author Replies Views Last Post
  How much faster is the HP Prime than the HP 50g ? Michael de Estrada 13 4,279 11-13-2013, 07:38 AM
Last Post: DeboT
  HP 20S Kate Field (Corvallis) 1 1,015 07-03-2013, 07:41 PM
Last Post: Peter Murphy (Livermore)
  Why is the 19BII faster than the 17BII(+)? Timo Labrenz 8 2,808 05-03-2012, 08:00 AM
Last Post: Xerxes
  HP 20S with very high "off" current Neil Hamilton (Ottawa) 2 1,234 04-01-2012, 11:49 AM
Last Post: Neil Hamilton (Ottawa)
  Some Vintage HP15Cs Faster than Others? Bruce Zastera 16 3,855 01-26-2012, 06:04 PM
Last Post: Bruce Zastera
  Amazing! An HP-32SII is faster than an HP-35s Michael de Estrada 24 5,999 08-04-2011, 01:08 PM
Last Post: Neil Hamilton (Ottawa)
  HP 20S recurring key identification Andrew 5 1,692 11-22-2010, 03:19 PM
Last Post: Walter B
  HP41 faster after crash and reset? Timo 2 1,262 03-15-2010, 01:40 PM
Last Post: Timo
  The best and faster and more sophisticated calculator of the world :-) Saile (Brazil) 4 1,656 12-18-2009, 07:21 AM
Last Post: Vieira, Luiz C. (Brazil)
  HP-20S Manual? Tom McCaffrey 1 955 10-26-2009, 10:25 PM
Last Post: Katie Wasserman

Forum Jump: