Optimization
Optimization with QB Logic
Use of XOR

XOR is called "exclusive OR" because either A or B must be true, but not both, for the result to be true.


IF A = 99 OR B = 3 THEN IF (a = 99) <> (b = 3) THEN...
is equivalent to

IF A = 99 XOR B = 3 THEN...
This is also equivalent:

IF (A = 99) - (B = 3) THEN...
Note:
1) The 2nd and 3rd code snips run as quickly, but not the first.
2) Watch the parentheses!

X Y XOR
--------------------
T T F
T F T
F T T
F F F
-Agamemnus


LogicChapterC - page last edited 2003-08-16 18:22:47 by 172.141.5.70 (home) (edit)
Blast WIKI - by RoboticBoy - edited and tweaked for our evil purposes by Hexadecimal Disaster