XOR
Author Message
XOR

Ok, I'm hardly in any sort of super-advanced math course, but I'm not
your average schmuck off the street either. Fact is, I've never
understood (perhaps never had the need to?) XOR. Could someone be kind
enough as to explain WHAT it does, in english (or french) terms?

--
Joe Drew
Anti-American extraordinare and QB programmer
In development, website at http://www.*-*-*.com/ ~hosehead/
Don't click on any links, the files don't exist yet. :)
My PGP key is available upon request, just send me an e-mail and it's
yours.

Sun, 02 Apr 2000 03:00:00 GMT
XOR

OK, so the XOR is a binary combinaison of 2 figures.
The english meaning of xor is (eXclusive OR), with means
true is the first or the second is true, but not the both
at a time.

A figure : 10
Another : 12
10 ==> 1010
12 ==> 1100

You should know the OR
1010
OR 1100
----
1110

10 OR 12 = 14

1 OR 1 (true or true) = 1 (true)
1 OR 0 (true or false) = 1 (true)
0 OR 1 (false or true) = 1 (true)
0 OR 0 (false or false) =0 (false)

And for the XOR :

1010
XOR 1100
----
0110

10 XOR 10 = 6

1 OR 1 (true xor true) = 0 (false)
1 OR 0 (true xor false) = 1 (true)
0 OR 1 (false xor true) = 1 (true)
0 OR 0 (false xor false) =0 (false)

That's all
You'll understand that : -) i XOR i = 0
-) i XOR 0 = i
-) i XOR 255 = NOT i if i is a byte

And if you want a french translation, just ask me :)

Mon, 03 Apr 2000 03:00:00 GMT
XOR

SPAMHATERidirect.com> writes

Quote:
>Ok, I'm hardly in any sort of super-advanced math course, but I'm not
>your average schmuck off the street either. Fact is, I've never
>understood (perhaps never had the need to?) XOR. Could someone be kind
>enough as to explain WHAT it does, in english (or french) terms?

It's used for all sorts of things, mainly involving the use of a byte to
store 8 independent 1-bit "numbers".  Here's one example.  Imagine you
have an 8-bit byte which you can output to some hardware to turn 8 lamps
on and off independently.

If the byte contained the decimal number 15, that is 00001111 in binary,
it would switch on the right hand four lamps.  If the number was
01010101 in binary (85 in decimal) then alternate lamps would be on.
Now, say you wanted to make the lamp which is second from the left flash
on and off, no matter what the other lamps were doing, you need a
function which will invert the state of that digit (shown as x here)
0x000000 without affecting the rest.  That function is XOR.

If you obey:

byte = byte XOR 128

then because 128 is 01000000 in binary it only affects the second lamp
from the left, and whatever byte was before, it remains the same but
with the second bit inverted either from 1 to 0 or 0 to 1.

If you repeat

byte = byte XOR 128

at regular intervals, the light will flash at regular intervals.

I have not come across a use for XOR on variables which contain values
used for arithmetic purposes.
--
Peter Hesketh, Mynyddbach, Gwent, UK
"Sex is not the answer.   Sex is the question.  Yes is the answer."

Mon, 03 Apr 2000 03:00:00 GMT
XOR

Quote:

> Ok, I'm hardly in any sort of super-advanced math course, but I'm not
> your average schmuck off the street either. Fact is, I've never
> understood (perhaps never had the need to?) XOR. Could someone be kind
> enough as to explain WHAT it does, in english (or french) terms?

XOR is exclusive or. That means "either this OR that, but not both". It
is a boolean operator and you can look it up in a qb help file table
AFAIK. Fe. you can write "if a xor b", then if a is true and b is false
or the other way round, the expression is true. Same as you would write
"if a or b and not(a and b)".

--
http://www.geocities.com/SiliconValley/Lakes/7784

Mon, 03 Apr 2000 03:00:00 GMT
XOR

Quote:

> Ok, I'm hardly in any sort of super-advanced math course, but I'm not
> your average schmuck off the street either. Fact is, I've never
> understood (perhaps never had the need to?) XOR. Could someone be kind
> enough as to explain WHAT it does, in english (or french) terms?

There are two basic uses I have seen for XOR.  One is toggling a bit or
bits, as others have responded in this thread.  The other isn't seen very
often, usually only in assembly language.  You can use three XORs to swap
the contents of two variables or registers like this:

XOR A,B
XOR B,A
XOR A,B
--
Judson McClendon          This is a faithful saying and worthy of all
Sun Valley Systems        acceptance, that Christ Jesus came into the

(please remove zzz from email id to respond)

Tue, 04 Apr 2000 03:00:00 GMT
XOR

Quote:
>Ok, I'm hardly in any sort of super-advanced math course, but I'm not
>your average schmuck off the street either. Fact is, I've never
>understood (perhaps never had the need to?) XOR. Could someone be kind
>enough as to explain WHAT it does, in english (or french) terms?

XOR stands for eXclusive OR. It works like normal OR except that 1 XOR 1 = 0
whereas 1 OR 1 = 1. In other words XOR is "one or the other BUT not both".

0 XOR 0 = 0
0 XOR 1 = 1
1 XOR 0 = 1
1 XOR 1 = 0

Alex Warren

www:   http://www.users.globalnet.co.uk/~dewarr/
icq:   4043750

Tue, 04 Apr 2000 03:00:00 GMT
XOR

Hi Joe,

Quote:

> Ok, I'm hardly in any sort of super-advanced math course, but I'm not
> your average schmuck off the street either. Fact is, I've never
> understood (perhaps never had the need to?) XOR. Could someone be kind
> enough as to explain WHAT it does, in english (or french) terms?

Oh, and in QBasic, it can be used to put and takeaway graphics without
going over what was there already.
PUT (x,y), image, XOR   'this puts the image in place
PUT (x,y), image, XOR   'removes the image (as long as x and y remain
the same as before)

Oh, you'll find that the colours change to horrible ones. There's a way
round this, but it's a bit long-winded.

Laz.

Tue, 04 Apr 2000 03:00:00 GMT
XOR

On Wed, 15 Oct 1997 23:24:53 -0400, Joe Drew

Quote:

>understood (perhaps never had the need to?) XOR. Could someone be kind
>enough as to explain WHAT it does, in english (or french) terms?

XOR is "eXclusive OR".  First we need to look at the "truth table" for OR
shown below:

OR            False          True
False        False          True
True          True            True

Where the 2 inputs to the OR operation are shown as row and column labels
and the matrix shows the result. Essentially OR returns "true" if either or
both of the inputs are "true".

XOR has the following truth table:

XOR         False          True
False        False          True
True          True            False

Note that now we get a "true" result only if one of the inputs is "true"
but if both are "false" or both are "true" we get a "false" output.

You can think of it as being "more selective" than an OR if you like. In
logic design XOR, NOR (not OR),  and NAND (not AND) are useful because they
allow you to simplify logic in many cases by stating a logical process in
one set of terms and then recasting it into fewer steps or electronic
components by applying transformations of one formulation of the problem
into different logical functions.

-- Regards --

Sid Lee - Calgary, Alberta, Canada (51d N, 114d West)

Wed, 05 Apr 2000 03:00:00 GMT
XOR

JD>Ok, I'm hardly in any sort of super-advanced math course, but I'm not
JD>your average schmuck off the street either. Fact is, I've never
JD>understood (perhaps never had the need to?) XOR. Could someone be kind
JD>enough as to explain WHAT it does, in english (or french) terms?

To understand XOR you need to understand OR and AND (understanding
binary helps too) and also the NOT operator.

Below for discussion's sake I'm using the value one (1) to indicate true
and the value zero (0) to indicate false.

1) OR
With OR if ANY or all of the values\conditions are true then the
result is true.

For example: 1 OR 0 is true because at least one of the values is 1.
0 OR 1 is true for the same reason.
1 OR 1 is also true since at least one value is 1.
0 OR 0 is false because no values are true (1).
2) AND
With AND, ALL of the values\conditions must be true (not zero) to
result in a true result.

For example:
1 AND 0 is false cause one value is zero (not true).
0 AND 1 is false for the same reason.
1 AND 1 is true because both values are 1.
0 AND 0 is false because both values are not true (0).
3) XOR
With XOR the result is true, if and only if, one of the two values are
true (1) and one value is false (0). If both values are true or both
values are false, the result is false since XOR demands that one of the
values\conditions be 1 (true) and the other be zero (false).

For example:
1 XOR 0 is true cause only one value is true.
0 XOR 1 is true for the same reason.
1 XOR 1 is false because both values are true and neither
are false (0).
0 XOR 0 is false because both values are false and neither
value is true (remember with XOR one value must be
true (1) and one value must be false (0) for the
result to be true.
4) NOT
The NOT operator reverses the values so that any 1 becomes zero and
any zero becomes a one. If we had the binary number 101 and used the
NOT operator on it the process would look like:

Original number: 101
After using NOT  010

So that any ones become zeros and any zeros become ones.

Of course I only used 2 values\conditions and I'm sure you already
know that one can have more than 2 values\conditions.
You might have something like:

IF ((Score% >= 100) AND (Strength% > 0) AND (Coins% > 0)) THEN
PRINT "YOU WIN!"
END IF

Where a player only wins if his score is at least 100 and his strength
is greater than zero and he has at least 1 coin (we don't award wins -
to the weak or anyone who is broke!).

In programming AND, and OR are the nuts and bolts of computer logic
(XOR less so). One thing about using AND, OR and XOR is to be careful
to properly use parenthesises very precisely so that your logic is
perfectly clear.

That is my understanding of OR, AND, XOR and NOT. Hope that helps.

- Robert

* OLX 2.1 TD * Nuke the gay whales for Christ!

Wed, 05 Apr 2000 03:00:00 GMT
XOR

Quote:
>   To understand XOR you need to understand OR and AND (understanding
>   binary helps too) and also the NOT operator.

<snip>

Quote:
>   That is my understanding of OR, AND, XOR and NOT. Hope that helps.

Thank you. I'm finally coming into real knowledge of boolean operators;
you have allowed my knowledge to expand exponentially. Once again,
thanks lots!

--
Joe Drew
Anti-American extraordinare and QB programmer
Don't click on any links, the files don't exist yet. :)
My PGP key is available upon request, just send me an e-mail and it's
yours.

Wed, 05 Apr 2000 03:00:00 GMT

 Page 1 of 1 [ 10 post ]

Relevant Pages
 2. XOR Line 4. XOR? 12. OR,XOR,AND