<?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 If a Number Is a Power of Two</title>
	<atom:link href="http://www.exploringbinary.com/how-to-check-if-a-number-is-a-power-of-two/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.exploringbinary.com/how-to-check-if-a-number-is-a-power-of-two/</link>
	<description>Binary Numbers, Binary Code, and Binary Logic</description>
	<lastBuildDate>Mon, 30 Jan 2012 01:37:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Big Eclipse</title>
		<link>http://www.exploringbinary.com/how-to-check-if-a-number-is-a-power-of-two/comment-page-1/#comment-4861</link>
		<dc:creator>Big Eclipse</dc:creator>
		<pubDate>Wed, 16 Feb 2011 22:01:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.exploringbinary.com/?p=78#comment-4861</guid>
		<description>Great article.  Love the Q &amp; A at the end.</description>
		<content:encoded><![CDATA[<p>Great article.  Love the Q &amp; A at the end.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Regan</title>
		<link>http://www.exploringbinary.com/how-to-check-if-a-number-is-a-power-of-two/comment-page-1/#comment-80</link>
		<dc:creator>Rick Regan</dc:creator>
		<pubDate>Thu, 04 Dec 2008 01:12:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.exploringbinary.com/?p=78#comment-80</guid>
		<description>Matt, that&#039;s correct, and probably the easiest thing to do if you have a computer or scientific calculator on hand. Note also, at least for positive integers, you could compute the prime factorization and check if all factors are 2 (if they are, the number is a power of two). If you have a computer, you could also check -- if the number is a positive integer -- how many 1 bits are set (one 1 bit means the number is a power of two).

But my goal for this article was to explore the nature of the powers of two, by making you suffer through &quot;pencil and paper&quot; arithmetic ;) . (I added a paragraph to the introduction to make that clear).

&lt;em&gt;Update:&lt;/em&gt; As for using logarithms in computer programs, beware that they may not come out exactly as integers for powers of two. This is due to how floating-point works. See &lt;a href=&quot;http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/&quot; title=&quot;Read Article &#8220;Ten Ways to Check if an Integer Is a Power Of Two in C&#8221;&quot; rel=&quot;nofollow&quot;&gt;``Ten Ways to Check if an Integer Is a Power Of Two in C&#039;&#039;&lt;/a&gt; for more info.</description>
		<content:encoded><![CDATA[<p>Matt, that&#8217;s correct, and probably the easiest thing to do if you have a computer or scientific calculator on hand. Note also, at least for positive integers, you could compute the prime factorization and check if all factors are 2 (if they are, the number is a power of two). If you have a computer, you could also check &#8212; if the number is a positive integer &#8212; how many 1 bits are set (one 1 bit means the number is a power of two).</p>
<p>But my goal for this article was to explore the nature of the powers of two, by making you suffer through &#8220;pencil and paper&#8221; arithmetic <img src='http://www.exploringbinary.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  . (I added a paragraph to the introduction to make that clear).</p>
<p><em>Update:</em> As for using logarithms in computer programs, beware that they may not come out exactly as integers for powers of two. This is due to how floating-point works. See <a href="http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/" title="Read Article &ldquo;Ten Ways to Check if an Integer Is a Power Of Two in C&rdquo;" rel="nofollow">&#8220;Ten Ways to Check if an Integer Is a Power Of Two in C&#8221;</a> for more info.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt C</title>
		<link>http://www.exploringbinary.com/how-to-check-if-a-number-is-a-power-of-two/comment-page-1/#comment-79</link>
		<dc:creator>Matt C</dc:creator>
		<pubDate>Wed, 03 Dec 2008 23:21:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.exploringbinary.com/?p=78#comment-79</guid>
		<description>You can take the log(base 2), or (log x / log 2) of a number and if its a integer value then its a power of 2.</description>
		<content:encoded><![CDATA[<p>You can take the log(base 2), or (log x / log 2) of a number and if its a integer value then its a power of 2.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

