DavidS wrote:You do have me curious, I am going have to look at the source for BBC BASIC V and see what is making this difference. My RPi is running withe the ARM at 600MHz, and SDRAM at 500MHz. I do not see how the SDRAM speed could make that much of a difference for this though maybe so, I have tried it with the ARM at 550MHz with the same exact results.
David your implementation of Ackermann is using integer variables while pygmy_giant's used floating point. this, I would suggest, would cause a noticeable difference in performance. As you know an integer in BBC BASIC fits neatly in one 32bit register - BBC BASIC V's FP format on the other hand doesn't (it's 40 bit). This would mean the use of slower Floating Point maths operations and also if values are being stacked the floating point values would require twice as many registers to be pushed/popped at each iteration than the Integer one (as the stacking would be occurring into SDRAM then the RAM speed might well have a bearing - possibly more so than the overall processor clock speed which is always greater than the RAM speed in any event).
I think these little differences are instructive as they show how to code for greatest efficiency and how important it is to compare "like with like" - Steve Drain's observations about using an iterative rather than recursive method to achieve the same end as Ackermann probably highlights that choosing the *right* algorithm from the start can be more productive than simply "tweaking" a suboptimal one....