HP 32S: <= and >= comparisons
|
05-06-2015, 08:20 PM
(This post was last modified: 05-06-2015 08:50 PM by Dieter.)
Post: #2
|
|||
|
|||
RE: HP 32S: <= and >= comparisons
(05-06-2015 03:13 PM)Dave Britten Wrote: Since the 32S lacks <= and >= comparisons, I'm trying to figure out the most efficient replacement. That's simple. Composing new tests by combining two others was a common technique back in the days of the 65, 67/97 and 41. I think this has been discussed earlier, at least in the old forum. Including the combination of three or even more consecutive tests. ;-) Edit: just found it – here. (05-06-2015 03:13 PM)Dave Britten Wrote: Are there better options than these? Well, unless the desired test is available (= 1 step) it obviously won't get shorter and faster than two steps. Which is what you did here. On the '41 I usually emulate X≥Y by having X≠Y followed by X>Y. (05-06-2015 03:13 PM)Dave Britten Wrote: Since the first comparison is the logical inverse of what we're looking for, and the second comparison (x=y?) will never be true if the first one is true, you're effectively writing "not x>y?" and "not x<y?", which are equivalent to "x<=y?" and "x>=y?" respectively. It's even simpler than this, the logic for these composite tests is always the same: NOT first condition OR second condition. This way you can also test if, say X>Y or X<0 (e.g. for range checks). Which makes this technique useful even for calculators that offer the full set of tests against Y and 0. Another method is shown in example 2 of the linked forum article: use the inverse test and have it followed by another one that always tests false, thus inverting the previous test. So X≥Y is equivalent to X<Y followed by, say, FS? 1 while flag 1 is clear. Dieter |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
HP 32S: <= and >= comparisons - Dave Britten - 05-06-2015, 03:13 PM
RE: HP 32S: <= and >= comparisons - Dieter - 05-06-2015 08:20 PM
RE: HP 32S: <= and >= comparisons - Dave Britten - 05-06-2015, 08:57 PM
|
User(s) browsing this thread: 2 Guest(s)