HP Forums

Full Version: HP 50G: Long Reals Run Faster than Reals?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
    %%>%
  ;
;
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.
Thanks for your suggestion, Dave.

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.
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.
Reference URL's