HP 50G: Long Reals Run Faster than Reals?
08-15-2015, 04:35 PM (This post was last modified: 08-15-2015 04:36 PM by Gerald H.)
Post: #1
 Gerald H Senior Member Posts: 1,627 Joined: May 2014
HP 50G: Long Reals Run Faster than Reals?
Below are two programmes to find the number of prime integers up to the input limit.

The programme using long reals requires less time than the one with reals.

Why?

Code:
 ::   CK1&Dispatch   BINT1   ::     DUP     %LN     DUPUNROT     %/     DUPUNROT     OVER     %IP     %3     %-     COERCE     ONE_DO     INDEX@     UNCOERCE     %*     OVER     %/     ROTOVER     %+     3UNROLL     LOOP     2DROP   ; ; ::   CK1&Dispatch   BINT1   ::     %>%%     DUP     %%LN     DUPUNROT     %%/     DUPUNROT     OVER     %%INT     %%3     %%-     %%>%     COERCE     ONE_DO     INDEX@     UNCOERCE%%     %%*     OVER     %%/     ROTOVER     %%+     3UNROLL     LOOP     2DROP     %%>%   ; ;
08-15-2015, 10:01 PM
Post: #2
 DavidM Senior Member Posts: 986 Joined: Dec 2013
RE: HP 50G: Long Reals Run Faster than Reals?
I've had similar results in the past. Don't know for sure, but I suspect that the short real math is actually implemented with long real operations. So the extra time would be a result of the extra conversions taking place behind the scenes. Shouldn't be too hard to confirm with Nosy, but I'm not able to verify at the moment.
08-16-2015, 05:37 AM (This post was last modified: 08-16-2015 05:43 AM by Gerald H.)
Post: #3
 Gerald H Senior Member Posts: 1,627 Joined: May 2014
RE: HP 50G: Long Reals Run Faster than Reals?

I have compared times for %%+ & %+, %%/ & %/, %%- & %- with the result that the individual real operations are faster for some input values, slower for others, than the individual long real operations. ( Loop from 1 to 1000, just the one command in the loop.)

My timings for the long real programme above were c 3% lower than for reals & on the 49G (1.19-6 & 2.10-7) more like 10% lower.
08-21-2015, 08:15 PM
Post: #4
 Han Senior Member Posts: 1,882 Joined: Dec 2013
RE: HP 50G: Long Reals Run Faster than Reals?
DavidM is correct. Even before the HP48 series (I know as far back as the HP42S), real-number operations were always done after promotion to extended reals. The internal algorithms were/are all done in extended real format and "packed" upon completion. Thus, even a pure SysRPL program that uses regular reals as opposed to extended reals will eventually accumulate enough conversion overhead that it becomes significantly noticeable.

You can check for yourself by simply decompiling one of the SysRPL words that deal with real-number operations using Jazz or the built-in disassembler.

Graph 3D | QPI | SolveSys
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)