Everything2
Near Matches
Ignore Exact
Full Text
Everything2

XOR

"XOR" is also a: user

created by Woundweavr

(idea) by Woundweavr (4 y) (print)   ?   (I like it!) Tue Mar 28 2000 at 4:34:43

Exculsive OR. This is a binary operator. It returns true or 1 if only 1 of its conditions are true. With 3 or more input, true is returned if an odd number of inputs are true. In C, this is represented by ^.

This is equal to !(A&&B) && (A||B).


(idea) by jakohn (2.3 mon) (print)   ?   (I like it!) Fri Apr 28 2000 at 22:23:16

XOR, exclusive OR, is a logical function. Here is the truth table for Q = A XOR B:
  
  A|B|Q
  -+-+-
  0|0|0
  0|1|1
  1|0|1
  1|1|0

For more than two inputs, XOR returns 1 if and only if an odd number of its inputs are 1. This is required to maintain the associative property. Consider:
(1 xor 0) xor 0 => 1 xor 0 => 1
1 xor (0 xor 0) => 1 xor 0 => 1
(1 xor 1) xor 1 => 0 xor 1 => 1
1 xor (1 xor 1) => 1 xor 0 => 1
but:
(1 xor 0) xor 1 => 1 xor 1 => 0
1 xor (0 xor 1) => 1 xor 1 => 0

Exclusive OR is also sometimes abbreviated EOR.

See also other logic functions: AND, OR, NOT, NAND, NOR, NXOR.


(thing) by ApoxyButt (9.1 mon) (print)   ?   (I like it!) Mon Jun 19 2000 at 22:50:47

The XOR operation can be used to swap two bit strings without using a third storage variable. To learn how, go to how to exhange two variables without using a third. It's fun!

(idea) by 2501 (7.2 y) (print)   ?   (I like it!) Wed Jun 21 2000 at 4:42:54

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


If we have two binary numbers "A" and "B" where:
A XOR B = C then:

C XOR A = B and C XOR B = A

For example:

101101110111011100 "A" XOR
101010001011100101 "B"
------------------
000111111100111001 "C" XOR
101010001011100101 "B"
------------------
101101110111011100 "A"



Coincidentally, This is also how microsoft encrypted their MS word documents awhile back. XOR'ing a 16 byte key throughout the document when the key can be extracted from the header of the file is not very smart.
I haven't checked to see if this is still how things are done, but if it is, Keep your eyes open for an example perl script

(thing) by core10k (6.2 y) (print)   ?   (I like it!) Fri Aug 11 2000 at 4:31:03

Also, xor was a primitive way to display sprites on a bitmap display when processor speed was low. By xoring the sprite, it would display, you could xor it again (thus erasing the sprite], and then xor the sprite somewhere else. A clever little hack.

(thing) by illusionist (8.2 mon) (print)   ?   (I like it!) Sun Jan 14 2001 at 21:25:19

A really good way to think about XOR is adding mod two and not "carrying" anything:

So:

  • 0 + 0 ~= 0 XOR 0 = 0
  • 0 + 1 ~= 0 XOR 1 = 1
  • 1 + 0 ~= 1 XOR 0 = 1
  • 1 + 1 (mod 2) ~= 1 XOR 1 = 0

This really helped in my understanding of XOR a little better, especially when working with LSFR's in cryptography.


(idea) by Nuteater (5.6 y) (print)   ?   (I like it!) Sat Jan 27 2001 at 19:55:55

XOR is (or was) a fast way to zero a register in assembly. For example, XOR AX,AX fills AX with 0's, because both sources are identical. This speeded the function by 1 clock or so in ancient x86 computers. Nowadays MOV AX,0x00 is as fast.

(idea) by boris.gruschko (7 y) (print)   ?   (I like it!) Thu Feb 01 2001 at 10:52:33

XOR encryption is considered the only mathematical proven way of non breakable encryption. It only works, if the key used for encryption is as long as the encrypted message and is being used only once. The key has to contain only hard random numbers. This way of keeping secrets is called the one time pad. If you fail to obey the rules above, the encryption is not safe anymore, since the standar cryptoanalytical methods can be applied to the encrypted text. The soviets for instance used the one time pads after the WWII for the communication with their agents in the USA. They generated their random numbers by letting someone type at a typewriter at random. The persons who did this used onle one hand, hence typing only on the left or the right sides of the typewriter's keyboard. This little hook was enough to crack the cipher

(idea) by Jargon (1.8 y) (print)   ?   (I like it!) Thu Jul 19 2001 at 18:54:44

XON = X = xref

xor /X'or/, /kzor/ conj.

Exclusive or. `A xor B' means `A or B, but not both'. "I want to get cherry pie xor a banana split." This derives from the technical use of the term as a function on truth-values that is true if exactly one of its two arguments is true.

--The Jargon File version 4.3.1, ed. ESR, autonoded by rescdsk.


(thing) by jbarn (6.4 y) (print)   ?   (I like it!) Mon Oct 15 2001 at 3:41:30

An internet services company based in Boulder, Colorado.

Excerpt from standard marketing propaganda:

Founded in 1991, XOR serves as a single point of accountability for building and running an eBusiness solution throughout all phases of its lifecycle, giving our clients the freedom to focus on what's really important to them - their core business.


(thing) by comp.sci (2.1 y) (print)   ?   (I like it!) Fri Nov 09 2001 at 14:46:17

XOR-Encryption

XOR is a bitwise operator and standard operation on bits and is called the 'eXclusive OR'.
XOR is true whenever an odd number of inputs is true.
In C-notation, XOR is written as ^ and in mathematical notation XOR is written as + with a circle around it.
Also note the following characteristics:

  • a XOR a = 0
  • a XOR b XOR b = a
This makes the encryption and decryption with one key (b) possible.
Let's take a look at the XOR-Encoding:
Let's assume we have a 3 letter key. We take the first letter of the plaintext and XOR it with the first letter of the key. Next, we take the second letter and XOR it with the second letter of the key. When we reach the fourth letter, we switch again to the first letter of the key. - We repeat the key.
An example:
"a" 01100001 XOR
"b" 01100010 =
00000011
We used the bitcode of ASCII 'a' as the plaintext and XORed it with the key ASCII 'b'.
Minding the fact that a XOR b XOR b = a, we can easily recover the plaintext:
"a xor b" 00000011 XOR
"b" 01100010 =
01100001 = ASCII "a"

(idea) by piq (1.9 mon) (print)   ?   (I like it!) Mon Jan 14 2002 at 15:16:57

In CMOS, XOR is carried out like:
                     _____
                       |
                   ____|____
             _   _|        _|
             A-||_     A-||_
                 _|    _   _|
             B-||_     B-||_
                  |_________|
                       |____________OUT
                     __|___          
               _   _|     _|      
               A-||_  B-||_
                    |______|
                     __|___          
               _   _|     _|      
               B-||_  A-||_
                    |______|
                     __|__
                      -|-
This, of course, is A XOR B, expressed as:
 _             _
(A * B) + (A * B)

A B | OUT
0 0 |  0
0 1 |  1
1 0 |  1
1 1 |  0

(idea) by BrianShader (1.5 y) (print)   ?   (I like it!) Tue May 21 2002 at 19:19:16

There is an interesting feature of the way XOR is defined for multiple inputs:

When ANDing multiple inputs, there is a "lazy" shortcut: if any of the inputs are 0, the output must also be 0, so there is no need to calculate the others.

Likewise, there is a shortcut for the OR gate. If any of the inputs are 1, the output must be 1; again, there is no need to resolve the other inputs.

The XOR gate has no such shortcut. Every single input must be calculated and tallied, as only an even number of TRUE inputs results in a TRUE return, and so any one input could reverse the output.


(thing) by foreverchanges (6.2 y) (print)   ?   (I like it!) Tue May 21 2002 at 19:53:57

I'll add two more very simple, area-efficient, and fast MOSFET implementations of the XOR. The XOR is a critical part of many digital circuits, such as random number generators and adders. Therefore efficient XOR implementations are very desirable. The implementations below are in most ways superior to the brute-force CMOS implementations given in previous writeups.

OUT = A (XOR) B

              _
              B
              |
            -----
            -----
           |     |
 A----------     -----
                     |
                     |
                     |         OUT
              B      |-----------             
              |      |
            -----    |
            -----    |
 _         |     |   |
 A----------     -----
                               

The NMOSFETs are called "pass transistors"--they only pass the binary values on the left if they are on. The biggest problem with this pass transistor implementation is that NMOSFETs pass weak 1's (they pass the power supply voltage minus the NMOS threshold voltage). This problem can be rectified by adding PMOSFETs gated with opposite-polarity signals in parallel to the NMOSFETs. Such a parallel combination of an NMOSFET and PMOSFET is called a transmission gate. Notice that this XOR implementation does not consume static power--one of the MOSFETs is off at all times (assuming the inversion of B is instantaneous--in reality it will probably be lagged, which creates problems).

And another one (with rail to rail swing--notice that it doesn't require A to be inverted!)

OUT = A (XOR) B




       B
       |
       |
       |
      -               B
    ||                |
 A-o||                o
    ||              -----
      -             -----
       |    OUT    |     |
       |-----------|     |___ A
       |           |     |
      -            |     |
    ||              -----
 A--||              -----
    ||                |
      -               |
       |              _
       |              B
       |
       _ 
       B


printable version
chaos

How to exchange two variables without using a third kid sister encryption Storing a doubly-linked list using just a single pointer field x0r
NAND XNOR XOR Problem You know you've been hacking too long when
What's your social security number? XON Table of 16 logic functions Live by the sword, die by the arrow
nor or xref Get two quarters from a soda machine using a dollar and smaller change
XOR swap Optimus Prime Exclusive Or continuum hypothesis
Add N to (X) and Rocky's Boots **
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help


cooled by donfreenut

Cool Staff Picks
Things you could have written:
The gods
Japanese writing system
United Fruit Company
The boy who spoke with the sky
The seizure I had last night
Automation Matron
How to improve your orgasms
It's OK to be a healthy geek
It's time to take the penny out of circulation
King of Birds
do re mi fa so la ti do
haggis
Myspace
New Writeups
antigravpussy
One fly amongst many(person)
sam512
Moon Base Shackleton, 1978(fiction)
Pavlovna
toy boy(person)
XWiz
tear jerker(review)
Heitah
Anarchy is Order(idea)
jessicaj
July 26, 2008(dream)
Berek
ABBA(person)
devolution
k-hole(place)
Nadine_2
The Sound Of Madness(review)
SwimmingMonkey