Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 drinking their drinks and smoking their pipes about the Monastery: (17)
As of 2014-07-29 15:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (219 votes), past polls