<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: n1 ^= n1? What is this? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768319#M722293</link>
    <description>You're right Rodney. I haven't done any serious C programming in 12 years. I no longer have a C manual at my desk. Had to rely on 12 year old memories (bad move!)&lt;BR /&gt;&lt;BR /&gt;Thanks for the clarification.&lt;BR /&gt;Marty</description>
    <pubDate>Fri, 19 Jul 2002 19:05:15 GMT</pubDate>
    <dc:creator>Martin Johnson</dc:creator>
    <dc:date>2002-07-19T19:05:15Z</dc:date>
    <item>
      <title>n1 ^= n1? What is this?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768314#M722288</link>
      <description>Hello Experts,&lt;BR /&gt;&lt;BR /&gt;I thought I knew something about C until I was given the job of making some minor changes to some very old (K &amp;amp; R , grrrr) C.&lt;BR /&gt;&lt;BR /&gt;This code is filled with statements like this:&lt;BR /&gt;n1 ^= n1;&lt;BR /&gt;n2 ^= n2;&lt;BR /&gt;&lt;BR /&gt;What is this doing. I took one out and the program instantly started core dumping.  BTW, n1 and n2 are ints.&lt;BR /&gt;&lt;BR /&gt;Please help quickly, Mary</description>
      <pubDate>Fri, 19 Jul 2002 18:20:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768314#M722288</guid>
      <dc:creator>Mary Rice</dc:creator>
      <dc:date>2002-07-19T18:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: n1 ^= n1? What is this?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768315#M722289</link>
      <description>Hi Mary:&lt;BR /&gt;&lt;BR /&gt;As soon as I saw this, I chuckled. Would you believe that this could have been written as:&lt;BR /&gt;n1 = n2 = 0;&lt;BR /&gt;&lt;BR /&gt;The original programmer must have been an assembly programmer at one time because XOR'ing a value with itself is an old assembly idiom to quickly zero a value (ususally a register). I'm even willing to bet that n1 and n2 were declared as register int's.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Jul 2002 18:24:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768315#M722289</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-07-19T18:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: n1 ^= n1? What is this?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768316#M722290</link>
      <description>damn bit twidlers, oh wait, I'm one of those, ouch...&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Fri, 19 Jul 2002 18:38:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768316#M722290</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-07-19T18:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: n1 ^= n1? What is this?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768317#M722291</link>
      <description>Clay,&lt;BR /&gt;&lt;BR /&gt;Your age is showing! :-)&lt;BR /&gt;&lt;BR /&gt;Haven't seen ^= in years. += is a little more common though, but I haven't that lately either.&lt;BR /&gt;&lt;BR /&gt;Marty &amp;lt; += increment by one&amp;gt;</description>
      <pubDate>Fri, 19 Jul 2002 18:53:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768317#M722291</guid>
      <dc:creator>Martin Johnson</dc:creator>
      <dc:date>2002-07-19T18:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: n1 ^= n1? What is this?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768318#M722292</link>
      <description>Actually Marty, += is increment by value to the right of =. ++ is increment by one.&lt;BR /&gt;&lt;BR /&gt;Ever since perl, I haven't had to do any C programming. (and I'm glad of it!)&lt;BR /&gt;&lt;BR /&gt;;-)&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Fri, 19 Jul 2002 19:00:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768318#M722292</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-07-19T19:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: n1 ^= n1? What is this?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768319#M722293</link>
      <description>You're right Rodney. I haven't done any serious C programming in 12 years. I no longer have a C manual at my desk. Had to rely on 12 year old memories (bad move!)&lt;BR /&gt;&lt;BR /&gt;Thanks for the clarification.&lt;BR /&gt;Marty</description>
      <pubDate>Fri, 19 Jul 2002 19:05:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768319#M722293</guid>
      <dc:creator>Martin Johnson</dc:creator>
      <dc:date>2002-07-19T19:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: n1 ^= n1? What is this?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768320#M722294</link>
      <description>Yep Clay, you nailed it. I put in some printf statements and that is exactly what is happening. I would have never figured that out. BTW, those were register ints.&lt;BR /&gt;&lt;BR /&gt;Now I have another question.  One of the functions does this:&lt;BR /&gt;&lt;BR /&gt;n1 ^= n2;&lt;BR /&gt;n2 ^= n1;&lt;BR /&gt;n1 ^= n2;&lt;BR /&gt;&lt;BR /&gt;Neither n1 nor n2 are zeroed so what is this crazy statement doing?&lt;BR /&gt;&lt;BR /&gt;I may have some more questions. I'll assign points then.&lt;BR /&gt;&lt;BR /&gt;Thank You,&lt;BR /&gt;Mary</description>
      <pubDate>Fri, 19 Jul 2002 19:12:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768320#M722294</guid>
      <dc:creator>Mary Rice</dc:creator>
      <dc:date>2002-07-19T19:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: n1 ^= n1? What is this?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768321#M722295</link>
      <description>I love this guy! Mary, where were you when they taught XOR's? Believe it or not, those 3 statements exchange the values of n1 and n2 without a temporary value.&lt;BR /&gt;&lt;BR /&gt;An equivalent would be:&lt;BR /&gt;temp = n1;&lt;BR /&gt;n1 = n2;&lt;BR /&gt;n2 = temp;&lt;BR /&gt;&lt;BR /&gt;I KNOW that this guy was an Assembly programmer now. His trick, would only work on wordsize or less variables.&lt;BR /&gt;&lt;BR /&gt;Let's see if I can show you how this works; remember and XOR compares two values and a bit is 1 only if exactly 1 of the same bit in both&lt;BR /&gt;values is 1.&lt;BR /&gt;&lt;BR /&gt;These are binary values:&lt;BR /&gt;Initial. n1 n2&lt;BR /&gt;........ 110 101&lt;BR /&gt;n1 ^= n2 011 101&lt;BR /&gt;n2 ^= n1 011 110&lt;BR /&gt;n1 ^= n2 101 110&lt;BR /&gt;&lt;BR /&gt;Note that n1 and n2 have now been swapped. If you put printf()'s before and after your C code, you should see the same. My psychic, Miss Cleo, tells me that this stuff was in some sort of sort function.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Jul 2002 19:22:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/n1-n1-what-is-this/m-p/2768321#M722295</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-07-19T19:22:40Z</dc:date>
    </item>
  </channel>
</rss>

