• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Need XOR solution
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need XOR solution


  • Subject: Re: Need XOR solution
  • From: "Marc K. Myers" <email@hidden>
  • Date: Wed, 07 Aug 2002 23:05:35 -0400
  • Organization: [very little]

> Subject: Re: Need XOR solution
> Date: Thu, 8 Aug 2002 02:05:43 +0100
> From: Nigel Garvey <email@hidden>
> To: "AppleScript Users" <email@hidden>
>
> "Marc K. Myers" wrote on Wed, 07 Aug 2002 16:13:17 -0400:
>
> >>
> >> 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?

[...Snip!...]

> Hope that's clear, not too simple, and/or not too complicated. ;-)

That's perfectly clear, with just the needed depth of explanation. I
understood the comparison of the modulated numbers as the actual
extraction of the XORed result, but the addition of 256 when it was true
threw me. Your explanation of the use of the extra left-hand bit and
how it rotates back to the rightmost position cleared that up for me.
You think like an assembly language programmer. Thanks, Nigel.

Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[8/7/02 11:03:20 PM]
_______________________________________________
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.

  • Follow-Ups:
    • Re: Need XOR solution
      • From: email@hidden (Michael Sullivan)
  • Prev by Date: Re: Not enough Memory errors
  • Next by Date: message from the Mail to FileMakerPro
  • Previous by thread: Re: Need XOR solution
  • Next by thread: Re: Need XOR solution
  • Index(es):
    • Date
    • Thread