Post Reply 
(11C) Reverse Integer
06-04-2018, 12:42 PM (This post was last modified: 06-04-2018 12:43 PM by Dieter.)
Post: #2
RE: (11C) Reverse Integer and Inverse Logic
(06-04-2018 10:16 AM)Gamo Wrote:  To do the Inverse Logic for X≥0 program must use X<0 twice.

X<0 and X<0 = X≥0

No, this does not work. Two consecutive X<0? tests do not give a X≥0? test. This will always test true, regardless of the input. But you can easily build the missing X≥0? with X≠0? followed by X>0?. General rule: if you have two consecutive tests commands, the result is a NOT(test1) OR test2. So X≠0? followed by X>0? means X=0? OR X>0? which is exactly what you want.

But then, if you want to set flag 1 for negative input, why don't you simply do it this way:

CF 1
X<0?
SF 1

Want it the other way round so that flag 1 is set for input ≥ 0 ?

SF 1
X<0?
CF 1

BTW, what is the flag 0 in the final steps used for? I cannot see that flag 0 is set or cleared anywhere. This should be a F?1 test, I think.

And now for the best part: All this is not required! As far as I can see flag 1 is supposed to be set if the input is negative. This way the output is returned with negative sign as well. But this does not require any tests. No X≥0? is required, no flag, no nothing. Simply omit the complete flag and X≥0 tests: the program will return the correct result both for positive and negative input. No additional measures are required.

That's the reason why your program version returns the correct results although the X<0? X<0? does not work.

So you can delete all steps between LBL A up to and including LBL 2. These are not required. At the end of the program, after the GTO 1 a simple RCL 0 is all you need. Don't believe me? Try it!

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(11C) Reverse Integer - Gamo - 06-04-2018, 10:16 AM
RE: (11C) Reverse Integer and Inverse Logic - Dieter - 06-04-2018 12:42 PM
RE: (11C) Reverse Integer - Dieter - 06-04-2018, 01:27 PM
RE: (11C) Reverse Integer - Dieter - 06-04-2018, 05:16 PM
RE: (11C) Reverse Integer - Dieter - 06-04-2018, 10:05 PM
RE: (11C) Reverse Integer - Gamo - 06-05-2018, 01:17 AM
RE: (11C) Reverse Integer - Dieter - 06-05-2018, 10:48 AM
RE: (11C) Reverse Integer - rprosperi - 06-05-2018, 01:17 PM



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