HP Forums
HP-9G programming bug - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: HP-9G programming bug (/thread-114698.html)



HP-9G programming bug - Xerxes - 05-28-2007

I tried to program the N-Queens Problem on the HP-9G for benchmarking and get a "NEST Er" without a plausible reason. After invastigating the problem, I have found the following:

N=3
S=0
Lbl 0:
S=S+N
IF(--N)THEN{GOTO 0}
PRINT S

This simple program for the sum of 1..n works only to N=3. The reason seems to be the jump out of the IF block more than 3 times.

Is it possible to avoid this problem?


Re: HP-9G programming bug - Raymond Del Tondo - 05-28-2007

Hi,

did you try other variable names?

Did you try with discrete operations,

like N=N-1 instead of '(--N)' ?

What does the doc say about that 'GOTO 0' construct ?

Or about the error message?

A nesting error indicates that either calling the

subprogram would exceed the the allowed nesting depth,

or maybe you forgot the correct return statement.

Raymond


Re: HP-9G programming bug - Xerxes - 05-28-2007

I have tried N=N-1 or other variables too. The "NEST Er" is discribed in the manual for the GOSUB statement with a maximum of 3 nesting depth.

Another example:

N=0
Lbl 0:
IF(1)THEN{N=N+1}
GOTO 0


N=0
Lbl0:
IF(1)THEN{N=N+1;GOTO 0}

The first example works but the second gives a "NEST Er".