The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





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
Post Reply 


Messages In This Thread
HP-71 Reals Faster Than Integers - toml_12953 - 07-01-2024 09:50 AM



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