06-24-2003, 09:07 PM
Quote:Here's mine, to turn a switch on if off, or off if on, without using XOR. x = 1 if on, and 0 if off.
Code:x = ((x = 0) AND 1) OR (1 AND (X = 0))
I was wrong. You are not implementing an XOR. Your code above is a very good approach and it works.
However, the second expression after the OR is exactly the same as the first expression, and therefore you can just exclude it, leaving the resultant code as:
Code:
x = ((x = 0) AND 1)
Another observation: You have introduced the fact that any expression, like (x=0), results in a true (-1) or false (0) condition. For example:
result = (a>b)
if a is greater than b, result is -1, true
if a is not greater than b, then result is 0, false.
You did great, Oracle!
*****