Post Reply 
HP71B RES bug?
01-02-2020, 02:05 PM
Post: #1
HP71B RES bug?
I had assumed RES = result of last expression (or last DISP expression)

However, RES may be affected by user defined function.

>10 DEF FNK(K,X) = K*X
>20 DEF FNR(X) = FNROOT(1,2,FVAR*FVAR-X)
>RUN

>1 + 0
  1
>FNK(2,RES) + FNK(3,RES) + FNK(4,RES)         ; expected 2*1 + 3*1 + 4*1 = 9
  32                                                                 ; got 2*1 + 3*2*1 + 4*3*2*1 = 32
>FNR(RES*2) + FNR(RES/2)                             ; expected √64+ √16 = 12
  10                                                                 ; got √64 + √4 = 10

Is this a bug ?
Find all posts by this user
Quote this message in a reply
01-02-2020, 03:29 PM (This post was last modified: 01-02-2020 03:31 PM by Sylvain Cote.)
Post: #2
RE: HP71B RES bug?
The reference manual says:
Code:
The HP-71 stores the result of each numeric assignment and calculator statement in a register re-
served for use by RES. This occurs prior to any rounding that may take place due to a SHORT or 
INTEGER destination variable. RES recalls the value currently stored in this register. RES can be 
particularly useful in iterative computations because it is much faster than variable references.

So I would assume that the equal of the user defined function fit the above description and it matches you're "got" values.

Step 1 : 1 + 0
Code:
1 + 0          // RES is set to 1

Step 2 : FNK(2,RES) + FNK(3,RES) + FNK(4,RES)
Code:
               // RES has 1
FNK(2,1)       // RES is set to 2
+              // push 2 to stack
FNK(3,2)       // RES is set to 6
+              // push 6 to stack
FNK(4,6)       // RES is set to 24
2 + 6 + 24     // do calculation on latest value and on pushed values
32             // value displayed, RES is set to 32

Step 3 : FNR(RES*2) + FNR(RES/2)
Code:
               // RES has 32
FNR(32*2)      // RES is set to 8
+              // push result to stack
FNR(8/2)       // RES is set to 2
8 + 2          // do calculation on latest value and on pushed values
10             // value displayed, RES is set to 10
Find all posts by this user
Quote this message in a reply
Post Reply 




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