<?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: How to check a given number is exact power of two?</title>
	<atom:link href="http://codereflect.com/2008/10/01/how-to-check-a-given-number-is-exact-power-of-two/feed/" rel="self" type="application/rss+xml" />
	<link>http://codereflect.com/2008/10/01/how-to-check-a-given-number-is-exact-power-of-two/</link>
	<description>on programming tips and trending topics...</description>
	<lastBuildDate>Sun, 29 Jan 2012 09:15:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: udhaya</title>
		<link>http://codereflect.com/2008/10/01/how-to-check-a-given-number-is-exact-power-of-two/comment-page-1/#comment-2480</link>
		<dc:creator>udhaya</dc:creator>
		<pubDate>Wed, 31 Mar 2010 11:47:20 +0000</pubDate>
		<guid isPermaLink="false">http://sarathc.wordpress.com/?p=550#comment-2480</guid>
		<description>Find if the given number is a power of 2.
//include math.h

void main()
{
int n,logval,powval;
printf(&quot;Enter a number to find whether it is s power of 2\n&quot;);
scanf(&quot;%d&quot;,&amp;n);
logval=log(n)/log(2);
powval=pow(2,logval);
if(powval==n)
printf(&quot;The number is a power of 2&quot;);
else
printf(&quot;The number is not a power of 2&quot;);
getch();
}</description>
		<content:encoded><![CDATA[<p>Find if the given number is a power of 2.<br />
//include math.h</p>
<p>void main()<br />
{<br />
int n,logval,powval;<br />
printf(&#8220;Enter a number to find whether it is s power of 2\n&#8221;);<br />
scanf(&#8220;%d&#8221;,&amp;n);<br />
logval=log(n)/log(2);<br />
powval=pow(2,logval);<br />
if(powval==n)<br />
printf(&#8220;The number is a power of 2&#8243;);<br />
else<br />
printf(&#8220;The number is not a power of 2&#8243;);<br />
getch();<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick</title>
		<link>http://codereflect.com/2008/10/01/how-to-check-a-given-number-is-exact-power-of-two/comment-page-1/#comment-2187</link>
		<dc:creator>Rick</dc:creator>
		<pubDate>Wed, 18 Feb 2009 14:33:38 +0000</pubDate>
		<guid isPermaLink="false">http://sarathc.wordpress.com/?p=550#comment-2187</guid>
		<description>Somehow my comment got cut off. It&#039;s supposed to say &quot;Since n is an int, it could be less than or equal to 0&quot;.  You need to add a check for this.</description>
		<content:encoded><![CDATA[<p>Somehow my comment got cut off. It&#8217;s supposed to say &#8220;Since n is an int, it could be less than or equal to 0&#8243;.  You need to add a check for this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick</title>
		<link>http://codereflect.com/2008/10/01/how-to-check-a-given-number-is-exact-power-of-two/comment-page-1/#comment-2188</link>
		<dc:creator>Rick</dc:creator>
		<pubDate>Wed, 18 Feb 2009 14:28:09 +0000</pubDate>
		<guid isPermaLink="false">http://sarathc.wordpress.com/?p=550#comment-2188</guid>
		<description>Zero is not a power of two, nor are negative numbers. Since n is an int,  it could be  0) &amp;&amp; (n&amp;(n-1))==0);

See my article http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/ . Specifically, the sections ``9. Decrement and Compare&#039;&#039; and ``How NOT to Check&#039;&#039;

Rick Regan</description>
		<content:encoded><![CDATA[<p>Zero is not a power of two, nor are negative numbers. Since n is an int,  it could be  0) &amp;&amp; (n&amp;(n-1))==0);</p>
<p>See my article <a href="http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/" rel="nofollow">http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/</a> . Specifically, the sections &#8220;9. Decrement and Compare&#8221; and &#8220;How NOT to Check&#8221;</p>
<p>Rick Regan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Faisal</title>
		<link>http://codereflect.com/2008/10/01/how-to-check-a-given-number-is-exact-power-of-two/comment-page-1/#comment-2186</link>
		<dc:creator>Faisal</dc:creator>
		<pubDate>Fri, 24 Oct 2008 12:46:19 +0000</pubDate>
		<guid isPermaLink="false">http://sarathc.wordpress.com/?p=550#comment-2186</guid>
		<description>This code also work in the same way
return (value &amp; -value) == value;</description>
		<content:encoded><![CDATA[<p>This code also work in the same way<br />
return (value &amp; -value) == value;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

