Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Re: Detecting transpositions

by sgifford (Prior)
on Aug 07, 2003 at 02:13 UTC ( [id://281693]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Detecting transpositions
in thread Detecting transpositions

It works because the xor of two bits is zero if and only if the two bits are the same:
0 ^ 0 = 0
1 ^ 1 = 0
0 ^ 1 = 1
1 ^ 0 = 1
So the xor of two characters (which are a string of 8 bits) will be 0 (8 0-bits) if and only if the two characters are the same.

Using xor on strings xors the characters from the first string with the characters in the second string, so in the places where the characters are identical the resulting character will be zero, and in all places where they differ it will be nonzero.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://281693]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-28 16:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found