Re: Need XOR solution
Re: Need XOR solution
- Subject: Re: Need XOR solution
- From: "Marc K. Myers" <email@hidden>
- Date: Wed, 07 Aug 2002 16:13:17 -0400
- Organization: [very little]
>
>> Date: Tue, 06 Aug 2002 16:33:17 -0400
>
>> Subject: Re: Need XOR solution
>
>> From: "Arthur J. Knapp" <email@hidden>
>
>> To: <email@hidden>
>
>>
>
>> > Date: Mon, 05 Aug 2002 18:45:28 -0400
>
>> > From: "Marc K. Myers" <email@hidden>
>
>> > Subject: Need XOR solution
>
>>
>
>> > Does anyone know of a reasonably fast way to XOR blocks of data
>
>together?
>
>
>
>> > ... I would appreciate it
>
>> > if someone could point me in the right direction.
>
>>
>
>> This is unlikely to be the right direction, but you may find
>
>> my "manual" XORing to be interesting:
>
>
>
>[...snip!...]
>
>
>I find it more than interesting; I find it mind-boggling. I've printed
>
>it out and will attempt to understand it gradually at my leisure. I
>
>really like the "Bitify" routine which is much simpler than the one I
>
>was playing with to get bytes as bit patterns.
>
>
You could use the brilliant "Fast ASCII" coverter from Arthur's script to
>
get the number value of each byte, and XOR them together with this:
>
>
on Xorify(n1, n2)
>
set xor to 0
>
repeat 8 times
>
if n1 mod 2 is not equal to n2 mod 2 then set xor to xor + 256
>
set n1 to n1 div 2
>
set n2 to n2 div 2
>
set xor to xor div 2
>
end repeat
>
-- return xor
>
end Xorify
That works beautifully, but even after "walking" through the eight
iterations with pencil and paper I still didn't understand *how* it
works. Honestly, I was amazed that I got the right answer after the
eighth pass through the loop! Could you explain it, briefly, for those
of us who are less mathematically inclined?
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[8/7/02 4:06:27 PM]
--
Those who lack nonvolatile memory are condemned to iterate.
-- John M. Ford
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.