(41) HP-16C+ - 16X=0? issue - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: (41) HP-16C+ - 16X=0? issue (/thread-20031.html) |
(41) HP-16C+ - 16X=0? issue - Bernd Grubert - 05-29-2023 09:04 PM Hello I am trying to port the IEEE conversion program from the HP-16C manual to the HP-16C emulator. I discovered a problem with the X=0? test of the HP-16C emulator for the HP-41. When I use the test program below, the test doesn't give the the results I would expect: Code: '1' displays 'X=0' whereas it should show 'X≠0'. Am I doing something wrong or is this a bug? Code: 01 LBL "TST" RE: (41) HP-16C+ - 16X=0? issue - Ángel Martin - 05-30-2023 06:28 AM Thanks for the bug report, I've corrected the wrong jump-to address in that code - pls. see the updated MOD file attached. RE: (41) HP-16C+ - 16X=0? issue - Bernd Grubert - 05-30-2023 08:39 PM Thanks for the update. That was fast! I'll check it tomorrow. (05-30-2023 06:28 AM)Ángel Martin Wrote: Thanks for the bug report, I've corrected the wrong jump-to address in that code - pls. see the updated MOD file attached. RE: (41) HP-16C+ - 16X=0? issue - Bernd Grubert - 06-09-2023 08:32 PM Hello Angel, I have written a small test program to check the comparisons. The test with 2CMP are all OK. There seems to be a small inconsistency when using 1CMP. The two representations of zero (0 and -0) are both evaluating to zero when using the comparisons X=0?, X#0?, etc. with my HP-16C, but not with the emulator. I have written a program to check the test. Here is the output: Code: 2CMP Here is the program with comments: Code: LBL "TST" RE: (41) HP-16C+ - 16X=0? issue - Ángel Martin - 06-15-2023 02:24 PM Lines 02 - 05 in the TST program set the word size to 2, why is that intended?? Testing manually X<0? and X<=0? on 1CMP with 16x = -0d returns the correct "YES" result, not sure why your program doesn't get the same outcome... will need to look at it with more time. But X=0? returns "NO", which I believe it is correct because -0d is not the same as 0d in binary, 1CMP representation with WS = 2 : 00 = 11 ?? Not quite, so I'll stick by the current "NO" isn't that right? RE: (41) HP-16C+ - 16X=0? issue - Bernd Grubert - 06-16-2023 04:29 PM Sorry, if I didn't explained it clearly. Quote:Lines 02 - 05 in the TST program set the word size to 2, why is that intended??I just choose the word size for simplicity, because there are only four numbers. In the one complement representation 00B and 11B are both zero, 01B is one and 10B is minus one. The outcome of the program itself is independent of word size if you set the starting value accordingly. Quote:But X=0? returns "NO", which I believe it is correct because -0d is not the same as 0dI just set the expected outcome (flag 05) to that of a physical HP-16C. Since 00B and 11B are both zero, on the HP-16C the "X=0?" test give true and the other "X...?" tests are consistent with that. Interestingly the "X=Y?" test with y: 11B and x: 00B on the stack results in "NO", which is correct also for the 16C-library. Remark: I don't use the one complement representation, myself. I was just curious how the HP-16C and the 16C-library behave for this special case. |