<?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: I&#8217;ve Got the Power (of 2)</title>
	<atom:link href="http://www.technicalinterviews.net/ive-got-the-power-of-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.technicalinterviews.net/ive-got-the-power-of-2/</link>
	<description>This site features a collection of common technical interview questions gathered by a group of programmers who have been through, and given, lots of technical interviews. There is an emphasis on C++ and game programming technical interviews, but most of the questions are relevant to any technical interview.</description>
	<lastBuildDate>Fri, 07 Oct 2011 20:18:23 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Mani</title>
		<link>http://www.technicalinterviews.net/ive-got-the-power-of-2/comment-page-1/#comment-2504</link>
		<dc:creator>Mani</dc:creator>
		<pubDate>Mon, 04 Jan 2010 05:23:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.technicalinterviews.net/ive-got-the-power-of-2/#comment-2504</guid>
		<description>A slight modification to the solution. If x is 0, then the solution would return true when it is supposed to return false so there has to be a check for x != 0. 

Check &lt;a href=&#039;http://www.mytechinterviews.com&#039; rel=&quot;nofollow&quot;&gt;My Tech Interviews&lt;/a&gt; for the complete solution and many more questions.

Thanks</description>
		<content:encoded><![CDATA[<p>A slight modification to the solution. If x is 0, then the solution would return true when it is supposed to return false so there has to be a check for x != 0. </p>
<p>Check <a href='http://www.mytechinterviews.com' rel="nofollow">My Tech Interviews</a> for the complete solution and many more questions.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Toddsa</title>
		<link>http://www.technicalinterviews.net/ive-got-the-power-of-2/comment-page-1/#comment-150</link>
		<dc:creator>Toddsa</dc:creator>
		<pubDate>Sun, 04 Mar 2007 23:14:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.technicalinterviews.net/ive-got-the-power-of-2/#comment-150</guid>
		<description>given x as an integer

(x &amp; (x-1)) will be 0 if x is a power of 2 and non zero if it is not. The reason is all power of 2&#039;s in binary will have a single set bit and (x-1) will have all set bits excluding x. for example x = 8 in binary is 1000 and (x-1) or 7 in binary is 111 so if you use the &amp; operator you will get. 

  1000
&amp; 0111
------
  0000

Any x this is not a power of 2 will result in some other non 0 result.</description>
		<content:encoded><![CDATA[<p>given x as an integer</p>
<p>(x &amp; (x-1)) will be 0 if x is a power of 2 and non zero if it is not. The reason is all power of 2&#8242;s in binary will have a single set bit and (x-1) will have all set bits excluding x. for example x = 8 in binary is 1000 and (x-1) or 7 in binary is 111 so if you use the &amp; operator you will get. </p>
<p>  1000<br />
&amp; 0111<br />
&#8212;&#8212;<br />
  0000</p>
<p>Any x this is not a power of 2 will result in some other non 0 result.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin</title>
		<link>http://www.technicalinterviews.net/ive-got-the-power-of-2/comment-page-1/#comment-45</link>
		<dc:creator>Robin</dc:creator>
		<pubDate>Thu, 01 Feb 2007 21:40:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.technicalinterviews.net/ive-got-the-power-of-2/#comment-45</guid>
		<description>This will be 0 if only one bit. 
otherwise, it is non-zero.</description>
		<content:encoded><![CDATA[<p>This will be 0 if only one bit.<br />
otherwise, it is non-zero.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin</title>
		<link>http://www.technicalinterviews.net/ive-got-the-power-of-2/comment-page-1/#comment-44</link>
		<dc:creator>Robin</dc:creator>
		<pubDate>Thu, 01 Feb 2007 21:39:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.technicalinterviews.net/ive-got-the-power-of-2/#comment-44</guid>
		<description>I could not put in the leftshit operator. 

  Answer is:

  X leftshift by 1 bit &amp;
  X leftshift by 2 bits &amp;
  X leftshift by 3 bits</description>
		<content:encoded><![CDATA[<p>I could not put in the leftshit operator. </p>
<p>  Answer is:</p>
<p>  X leftshift by 1 bit &amp;<br />
  X leftshift by 2 bits &amp;<br />
  X leftshift by 3 bits</p>
]]></content:encoded>
	</item>
</channel>
</rss>

