HP 15C conditional does not behave as expected
|
05-07-2021, 09:13 AM
(This post was last modified: 05-07-2021 09:17 AM by Siegfried.)
Post: #1
|
|||
|
|||
HP 15C conditional does not behave as expected
Using the below code with the following parameters:
1900 in register 3 -31.24 in register 2 8600 in x the value in x before the conditional test X>Y? (f TEST 7) is 894.4946 and the value in y is 1. The test should therefore test positive and the GTO .0 should be executed. It isn't however. Any hints what I am missing / doing wrong would be appreciated. I have verified that Y=1 using an R/S before the conditional. P.S.: This is a correction for minimum safe heights for aircraft to account for low temperature taken from the draft of the new PANS-OPS (where a wrong formula has been published for decades). Therefore all altitude related values are in feet but temperatures are C/K. Code: HP 15C |
|||
05-07-2021, 12:17 PM
Post: #2
|
|||
|
|||
RE: HP 15C conditional does not behave as expected
No idea if this is related but it appears there's a typo in this command:
PHP Code: RCL +.0 'add T0 All other operations use register 0, while this one uses .0, a different register, and could be leading to an unexpected value. --Bob Prosperi |
|||
05-07-2021, 03:56 PM
Post: #3
|
|||
|
|||
RE: HP 15C conditional does not behave as expected
(05-07-2021 12:17 PM)rprosperi Wrote: All other operations use register 0, while this one uses .0, a different register, and could be leading to an unexpected value. I store one of the constants into 0 and the other into .0, so this should be correct. I tried essentially the same code on the WP-34S emulator in the meantime and it works flawlessly there. |
|||
05-07-2021, 04:22 PM
(This post was last modified: 05-07-2021 07:59 PM by Gene.)
Post: #4
|
|||
|
|||
RE: HP 15C conditional does not behave as expected
Works fine for me as you have written it out on a 15c emulator. Don't have the physical unit with me at the moment.
Key codes to check: Code: 42 21 11 |
|||
05-07-2021, 06:45 PM
(This post was last modified: 05-07-2021 08:13 PM by Siegfried.)
Post: #5
|
|||
|
|||
RE: HP 15C conditional does not behave as expected
I think you got the loop label wrong which is .0 (corresponding to the GTO .0 at the end) which you have listed as
Code: 42 21 0 May I ask what your result is on program termination? I get the 894.xxx but that's wrong as the comparison should result in a few more loops and end up around 994. I get the same result on a real HP-15C and nonpareil-15c. I also tried this on a HP-41CX and get the same behaviour. I have added an R/S to check the stack before the conditional test and have verified X=894.5956 and Y=1. So when Testing X>Y? the result is TRUE and either calculator should continue on the line after the conditional test (that is the GTO .0 instruction) but it stops on the R/S one line further. (05-07-2021 04:22 PM)Gene Wrote: Works fine for me as you have written it out on a 15c emulator. Don't have the physical unit with me at the moment. |
|||
05-07-2021, 08:03 PM
Post: #6
|
|||
|
|||
RE: HP 15C conditional does not behave as expected
Sorry, corrected the .0 typo in the previous post.
It terminates with 894.595563 in the X register. The Y register contains 895.4946483. The TEST 7 instruction is working properly when the Y register contains a 1 the first time through the loop. I put a R/S before the test and checked a few loops. The app is the iOS 15C SciCalc app. |
|||
05-07-2021, 08:19 PM
Post: #7
|
|||
|
|||
RE: HP 15C conditional does not behave as expected
Thank you, Gene!
I think my error is somewhere in the code after LBL .0 which seems to behave differently than I think it does. It's quite some time since I last dabbled with this... (05-07-2021 08:03 PM)Gene Wrote: Sorry, corrected the .0 typo in the previous post. |
|||
05-07-2021, 08:25 PM
Post: #8
|
|||
|
|||
RE: HP 15C conditional does not behave as expected | |||
05-07-2021, 08:40 PM
Post: #9
|
|||
|
|||
RE: HP 15C conditional does not behave as expected
That's it ! Albert found it.
You need TWO ENTER statements after the LBL .0 When I run it that way, it ends with the answer of 994.65933422 |
|||
05-07-2021, 09:04 PM
Post: #10
|
|||
|
|||
RE: HP 15C conditional does not behave as expected
(05-07-2021 08:40 PM)Gene Wrote: That's it ! Albert found it.Thank you very much! I just returned here to report that I had found the missing ENTER just to find my conclusion confirmed before I had reached it. I had forgotten about the stack lift inhibit. Now I need to give that WP-34s program another look to find out why it worked there. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)