<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Saving an Operation or 20</title>
	<atom:link href="http://thesnarky.com/2007/01/31/saving-an-operation-or-20/feed/" rel="self" type="application/rss+xml" />
	<link>http://thesnarky.com/2007/01/31/saving-an-operation-or-20/</link>
	<description>The Words of the One Who Calls Himself a Philosopher</description>
	<lastBuildDate>Tue, 26 Oct 2010 22:13:34 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Adam Helps</title>
		<link>http://thesnarky.com/2007/01/31/saving-an-operation-or-20/comment-page-1/#comment-4162</link>
		<dc:creator>Adam Helps</dc:creator>
		<pubDate>Wed, 31 Jan 2007 21:08:04 +0000</pubDate>
		<guid isPermaLink="false">http://thesnarky.com/archives/128#comment-4162</guid>
		<description>Snarky made explicit casting illegal too, but assigning an int to an unsigned is an implicit cast, so I think I&#039;m OK...

int logical_not( int x )
{
   unsigned y = x;
   y = (y &gt;&gt; 1) &#124; (y &amp; 1);
   y = y + ~0;
   return y &gt;&gt; 31;
}

The basic idea is to create some value that is positive (and greater than zero) if any bits are set and zero if no bits are set; I then subtract 1 from that value. If the result is negative, I had a 0; if the result is positive, I had a non-zero.</description>
		<content:encoded><![CDATA[<p>Snarky made explicit casting illegal too, but assigning an int to an unsigned is an implicit cast, so I think I&#8217;m OK&#8230;</p>
<p>int logical_not( int x )<br />
{<br />
   unsigned y = x;<br />
   y = (y >> 1) | (y &#038; 1);<br />
   y = y + ~0;<br />
   return y >> 31;<br />
}</p>
<p>The basic idea is to create some value that is positive (and greater than zero) if any bits are set and zero if no bits are set; I then subtract 1 from that value. If the result is negative, I had a 0; if the result is positive, I had a non-zero.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Snarky</title>
		<link>http://thesnarky.com/2007/01/31/saving-an-operation-or-20/comment-page-1/#comment-4160</link>
		<dc:creator>Snarky</dc:creator>
		<pubDate>Wed, 31 Jan 2007 18:00:31 +0000</pubDate>
		<guid isPermaLink="false">http://thesnarky.com/archives/128#comment-4160</guid>
		<description>Bah, yea, additional rules left unstated.

Return 0 for false, 1 for true. And you can only use:
~
&gt;&gt;
&lt;&lt;
&amp;
&#124;
+
^

I realized last night going to bed this answer would pop up, so.... there&#039;s the extra rules to actually make it *hard*.</description>
		<content:encoded><![CDATA[<p>Bah, yea, additional rules left unstated.</p>
<p>Return 0 for false, 1 for true. And you can only use:<br />
~<br />
>><br />
<<<br />
&#038;<br />
|<br />
+<br />
^</p>
<p>I realized last night going to bed this answer would pop up, so&#8230;. there&#8217;s the extra rules to actually make it *hard*.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://thesnarky.com/2007/01/31/saving-an-operation-or-20/comment-page-1/#comment-4159</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 31 Jan 2007 16:40:43 +0000</pubDate>
		<guid isPermaLink="false">http://thesnarky.com/archives/128#comment-4159</guid>
		<description>int logical_not( int x ) {
   return x &amp;&amp; 1;
}</description>
		<content:encoded><![CDATA[<p>int logical_not( int x ) {<br />
   return x &amp;&amp; 1;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Harkins</title>
		<link>http://thesnarky.com/2007/01/31/saving-an-operation-or-20/comment-page-1/#comment-4158</link>
		<dc:creator>Peter Harkins</dc:creator>
		<pubDate>Wed, 31 Jan 2007 15:21:55 +0000</pubDate>
		<guid isPermaLink="false">http://thesnarky.com/archives/128#comment-4158</guid>
		<description>One operation, I guess:

int logical_not(int x) {
  return !x;
}

It has no tests or control structures, but as you and your friend both broke it down so far I&#039;m guessing there was an additional rule you&#039;ve left unstated?</description>
		<content:encoded><![CDATA[<p>One operation, I guess:</p>
<p>int logical_not(int x) {<br />
  return !x;<br />
}</p>
<p>It has no tests or control structures, but as you and your friend both broke it down so far I&#8217;m guessing there was an additional rule you&#8217;ve left unstated?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

