Post Reply 
HP-71 Reals Faster Than Integers
07-01-2024, 09:50 AM (This post was last modified: 07-01-2024 09:51 AM by toml_12953.)
Post: #1
HP-71 Reals Faster Than Integers
On some computers, using integers not only saves space but calculations are done faster. On the HP-71B, integers do save space but are slower than reals. In the N-Queens program (below) I commented out lines 10 and 30 and the runtime dropped from 2:57 to 2:35

Code:
5 T0=TIME 
10 INTEGER R,X,S,Y,T
20 R=8                   
30 INTEGER A(R)
40 IF X=R THEN 180
50 X=X+1
60 A(X)=R
70 S=S+1
80 Y=X
90 Y=Y-1
100 IF Y=0 THEN 40
110 T=A(X)-A(Y)
120 IF T=0 THEN 140
130 IF X-Y<>ABS(T) THEN 90
140 A(X)=A(X)-1
150 IF A(X) THEN 70
160 X=X-1
170 IF X THEN 140
180 PRINT S
190 T0=TIME-T0
200 PRINT USING "'RUNTIME: ',ZZ,':',ZZ.DD";T0 DIV 60,MOD(T0,60)
210 END

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
07-01-2024, 10:21 AM
Post: #2
RE: HP-71 Reals Faster Than Integers
This could have something to do with the fact that the registers of the Saturn CPU are optimised for the storage and manipulation of floating point numbers.

Current daily driver: HP 71B w/FRAM 71B
Find all posts by this user
Quote this message in a reply
Yesterday, 03:46 AM (This post was last modified: Yesterday 03:49 AM by brouhaha.)
Post: #3
RE: HP-71 Reals Faster Than Integers
I haven't checked, but it's possible that all the calculations are done in floating point, and then converted to integers for storage. Float to int could perhaps be a bit slow, though int to float should be fast. But still, it's extra conversions.

The Saturn processor architecture is definitely designed to perform _reasonably_ efficient floating point, but nevertheless, it can perform arithmetic on binary integers of up to 64 bits MUCH faster than floating point. It can do a 64-bit integer (either bniary or BCD) addition or subtraction in about 30 microseconds in the 71B I haven't timed it, but floating point calculations take hundreds of instructions, so probably at least 100x slow than the 64-bit integer operatinos.

That's the raw processor capability, which is why I think the user-level slowness with integers is a result of software architecture decisions, not that the CPU is faster at floating point, since it clearly isn't.
Find all posts by this user
Quote this message in a reply
Yesterday, 04:49 AM
Post: #4
RE: HP-71 Reals Faster Than Integers
I agree, my immediate suspicion was that computations were being done in floating point regardless.

The Saturn is actually pretty good with integers up to 64 bits in length.
They are much faster than floating point equivalents despite the apparent optimisations for floating point arithmetic.
Find all posts by this user
Quote this message in a reply
Yesterday, 07:24 AM
Post: #5
RE: HP-71 Reals Faster Than Integers
(Yesterday 03:46 AM)brouhaha Wrote:  I haven't checked, but it's possible that all the calculations are done in floating point, and then converted to integers for storage. Float to int could perhaps be a bit slow, though int to float should be fast. But still, it's extra conversions.

Yes, that's exactly the reason. All calculations on the HP-71 internal "Math Stack" (in RPN form) are done on floating point numbers.

The HP-75, as I indicated several times, has a clever "fast integer processing" feature.
When a REAL-type variable holds a integer value, then the calculations are done by integer routines, about 2x faster.
Still, even on the HP-75, INTEGER- and SHORT-type variables are slower and must be used only to save RAM or disc space.

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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