Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Bitwise Operators - TT&^/TT

by TheoPetersen (Priest)
on Jul 25, 2001 at 00:55 UTC ( #99482=note: print w/ replies, xml ) Need Help??


in reply to Bitwise Operators - &^

but when 155 and 105 are XORed, that produces 240, not 242.

Says who? The exclusive or of two bit patterns contains a one for each mismatch pair of bits and a zero for each matched pair. Thus for 155 and 105:

# 1001 1011 - 155 # 0110 1001 - 105 # 1111 0010 - 242
The fun thing about XOR is that if you XOR the result with one of the input values, you get the other input value back:
# 1001 1011 - 155 # 1111 0010 - 242 # 0110 1001 - 105
Thus various encryption schemes (and some fun graphics programming on early PCs :)


Comment on Re: Bitwise Operators - TT&^/TT
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (16)
As of 2015-07-06 12:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (74 votes), past polls