<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Exploring Binary &#187; Binary numbers</title>
	<atom:link href="http://www.exploringbinary.com/category/binary-numbers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.exploringbinary.com</link>
	<description>Binary Numbers, Binary Code, and Binary Logic</description>
	<lastBuildDate>Tue, 31 Jan 2012 16:38:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Binary Addition</title>
		<link>http://www.exploringbinary.com/binary-addition/</link>
		<comments>http://www.exploringbinary.com/binary-addition/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 18:15:19 +0000</pubDate>
		<dc:creator>Rick Regan</dc:creator>
				<category><![CDATA[Binary numbers]]></category>
		<category><![CDATA[Binary arithmetic]]></category>
		<category><![CDATA[Binary integers]]></category>
		<category><![CDATA[Convert to binary]]></category>
		<category><![CDATA[Convert to decimal]]></category>

		<guid isPermaLink="false">http://www.exploringbinary.com/?p=358</guid>
		<description><![CDATA[This is the first of a four part series on binary arithmetic, which I&#8217;m writing as a supplement to my binary calculator. This article introduces binary arithmetic, and then discusses binary addition. Binary Arithmetic Binary arithmetic is of interest because that&#8217;s how computers do math. When implemented in computers, many things must be taken into [...]<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/binary-addition/">Binary Addition</a></p>
]]></description>
			<content:encoded><![CDATA[<p><em>This is the first of a four part series on binary arithmetic, which I&#8217;m writing as a supplement to my <a title="Rick Regan's &ldquo;Binary Calculator&rdquo;" href="http://www.exploringbinary.com/binary-calculator/">binary calculator</a>. This article introduces binary arithmetic, and then discusses binary addition.</em></p>
<div class="wp-caption aligncenter" style="width: 203px"><img src="http://www.exploringbinary.com/wp-content/uploads/BinaryAdditionExample.png" alt="An Example of Binary Addition" width="193" height="159"/><p class="wp-caption-text">Example of Binary Addition</p></div>
<p><span id="more-358"></span></p>
<h2>Binary Arithmetic</h2>
<p>Binary arithmetic is of interest because that&#8217;s how computers do math. When implemented in computers, many things must be taken into account: format (fixed-point, floating-point, etc.), word size (8-bit, 16-bit, 32-bit, etc.), sign representation (sign-magnitude, ones&#8217; complement, two&#8217;s complement, etc.), overflow (when numbers are too big), and underflow (when numbers are too small). Furthermore, there is the design of the circuits to perform the algorithms (full adders, half adders, ripple carry adders, carry-lookahead adders, restoring dividers, non-restoring dividers, etc.). These are not inherent properties of binary arithmetic &#8212; they&#8217;re just implementation issues.</p>
<p>The truth is, in its purest form, binary arithmetic is very simple. The same &ldquo;pencil and paper&rdquo; algorithms you learned in grade school work for binary numbers. All you do differently is apply the &ldquo;facts&rdquo; for binary numerals, the (small) set of rules for manipulating 0s and 1s. And binary numbers on paper are written as you&#8217;d expect: without leading zeros, and with a minus sign (&lsquo;-&rsquo;) if negative.</p>
<p>In my series of articles, I will explain the pure forms of the four basic operations of binary arithmetic: addition, subtraction, multiplication, and division. In this first article, I will discuss binary addition.</p>
<h2>Decimal Addition</h2>
<p>To add two multiple-digit decimal numbers, you first need to know how to add two single-digit decimal numbers. This requires the memorization of 100 facts, or 55 facts if you exclude the commutative or &ldquo;turnaround&rdquo; facts. Also, because of carries, you need to know ten additional facts: 10 + 0 = 10, 10 + 1 = 11, &#8230; , 10 + 9 = 19. The latter apply when there&#8217;s a carry (always 1) and the &ldquo;top&rdquo; digit is 9.</p>
<table class="center" border="1" summary="109 Decimal Addition Facts">
<caption><strong>Decimal Addition Facts</strong></caption>
<tbody>
<tr>
<th class="center">+</th>
<th class="center internal_border_bottom">0</th>
<th class="center internal_border_bottom">1</th>
<th class="center internal_border_bottom">2</th>
<th class="center internal_border_bottom">3</th>
<th class="center internal_border_bottom">4</th>
<th class="center internal_border_bottom">5</th>
<th class="center internal_border_bottom">6</th>
<th class="center internal_border_bottom">7</th>
<th class="center internal_border_bottom">8</th>
<th class="center internal_border_bottom">9</th>
<th class="center internal_border_bottom">10</th>
</tr>
<tr>
<td class="center internal_border_right"><strong>0</strong></td>
<td class="center">0</td>
<td class="center grayed">1</td>
<td class="center grayed">2</td>
<td class="center grayed">3</td>
<td class="center grayed">4</td>
<td class="center grayed">5</td>
<td class="center grayed">6</td>
<td class="center grayed">7</td>
<td class="center grayed">8</td>
<td class="center grayed">9</td>
<td class="center grayed">10</td>
</tr>
<tr>
<td class="center internal_border_right"><strong>1</strong></td>
<td class="center">1</td>
<td class="center">2</td>
<td class="center grayed">3</td>
<td class="center grayed">4</td>
<td class="center grayed">5</td>
<td class="center grayed">6</td>
<td class="center grayed">7</td>
<td class="center grayed">8</td>
<td class="center grayed">9</td>
<td class="center grayed">10</td>
<td class="center grayed">11</td>
</tr>
<tr>
<td class="center internal_border_right"><strong>2</strong></td>
<td class="center">2</td>
<td class="center">3</td>
<td class="center">4</td>
<td class="center grayed">5</td>
<td class="center grayed">6</td>
<td class="center grayed">7</td>
<td class="center grayed">8</td>
<td class="center grayed">9</td>
<td class="center grayed">10</td>
<td class="center grayed">11</td>
<td class="center grayed">12</td>
</tr>
<tr>
<td class="center internal_border_right"><strong>3</strong></td>
<td class="center">3</td>
<td class="center">4</td>
<td class="center">5</td>
<td class="center">6</td>
<td class="center grayed">7</td>
<td class="center grayed">8</td>
<td class="center grayed">9</td>
<td class="center grayed">10</td>
<td class="center grayed">11</td>
<td class="center grayed">12</td>
<td class="center grayed">13</td>
</tr>
<tr>
<td class="center internal_border_right"><strong>4</strong></td>
<td class="center">4</td>
<td class="center">5</td>
<td class="center">6</td>
<td class="center">7</td>
<td class="center">8</td>
<td class="center grayed">9</td>
<td class="center grayed">10</td>
<td class="center grayed">11</td>
<td class="center grayed">12</td>
<td class="center grayed">13</td>
<td class="center grayed">14</td>
</tr>
<tr>
<td class="center internal_border_right"><strong>5</strong></td>
<td class="center">5</td>
<td class="center">6</td>
<td class="center">7</td>
<td class="center">8</td>
<td class="center">9</td>
<td class="center">10</td>
<td class="center grayed">11</td>
<td class="center grayed">12</td>
<td class="center grayed">13</td>
<td class="center grayed">14</td>
<td class="center grayed">15</td>
</tr>
<tr>
<td class="center internal_border_right"><strong>6</strong></td>
<td class="center">6</td>
<td class="center">7</td>
<td class="center">8</td>
<td class="center">9</td>
<td class="center">10</td>
<td class="center">11</td>
<td class="center">12</td>
<td class="center grayed">13</td>
<td class="center grayed">14</td>
<td class="center grayed">15</td>
<td class="center grayed">16</td>
</tr>
<tr>
<td class="center internal_border_right"><strong>7</strong></td>
<td class="center">7</td>
<td class="center">8</td>
<td class="center">9</td>
<td class="center">10</td>
<td class="center">11</td>
<td class="center">12</td>
<td class="center">13</td>
<td class="center">14</td>
<td class="center grayed">15</td>
<td class="center grayed">16</td>
<td class="center grayed">17</td>
</tr>
<tr>
<td class="center internal_border_right"><strong>8</strong></td>
<td class="center">8</td>
<td class="center">9</td>
<td class="center">10</td>
<td class="center">11</td>
<td class="center">12</td>
<td class="center">13</td>
<td class="center">14</td>
<td class="center">15</td>
<td class="center">16</td>
<td class="center grayed">17</td>
<td class="center grayed">18</td>
</tr>
<tr>
<td class="center internal_border_right"><strong>9</strong></td>
<td class="center">9</td>
<td class="center">10</td>
<td class="center">11</td>
<td class="center">12</td>
<td class="center">13</td>
<td class="center">14</td>
<td class="center">15</td>
<td class="center">16</td>
<td class="center">17</td>
<td class="center">18</td>
<td class="center grayed">19</td>
</tr>
<tr>
<td class="center internal_border_right"><strong>10</strong></td>
<td class="center">10</td>
<td class="center">11</td>
<td class="center">12</td>
<td class="center">13</td>
<td class="center">14</td>
<td class="center">15</td>
<td class="center">16</td>
<td class="center">17</td>
<td class="center">18</td>
<td class="center">19</td>
<td class="center">-</td>
</tr>
</tbody>
</table>
<p>For example, let&#8217;s add 19.7 and 12.8:</p>
<div class="wp-caption aligncenter" style="width: 127px"><img src="http://www.exploringbinary.com/wp-content/uploads/DecimalAdditionExample.png" alt="An Example of Decimal Addition" width="117" height="137"/><p class="wp-caption-text">Example of Decimal Addition</p></div>
<p>Let&#8217;s think about what a carry does. It turns our neat &#8220;add two single-digit numbers per column&#8221; problem into &#8220;add <em>three</em> single-digit numbers per column.&#8221; But addition is a binary (in a different sense) operation, meaning it operates on two numbers at a time. So what we do is add the carry to the &ldquo;top&rdquo; digit, and then add that result to the &ldquo;bottom&rdquo; digit. The first addition may result in a double digit answer (10), which means we&#8217;d have to use one of the ten extra facts to do the second addition.</p>
<p>In our example, the carry is added to 9, giving 10, and then 10 is added to 2, giving 12. The second addition used the extra &#8220;10 + 2 = 12&#8243; fact.</p>
<div class="wp-caption aligncenter" style="width: 139px"><img src="http://www.exploringbinary.com/wp-content/uploads/DecimalAdditionExampleExtra.png" alt="Decimal Addition Showing Intermediate Additions" width="129" height="151"/><p class="wp-caption-text">Decimal Addition Showing Intermediate Additions</p></div>
<h2>Binary Addition</h2>
<p>Binary addition works the same way as decimal addition, except it uses a different &#8212; and much smaller &#8212; set of facts. There are only four single-digit facts, or three if you exclude the commutative fact. To handle carries, you need to know two additional facts, 10 + 0 = 10 and 10 + 1 = 11. (<a title="Read Rick Regan's Article &ldquo;There Are 10 Types of People …&rdquo;" href="http://www.exploringbinary.com/there-are-10-types-of-people/">Resist the urge to pronounce 10 as ten</a> and 11 as eleven; either call them one-zero and one-one, or two and three.) The latter apply when there’s a carry (always 1) and the “top” digit is 1.</p>
<table class="center" border="1" summary="8 Binary Addition Facts">
<caption><strong>Binary Addition Facts</strong></caption>
<tbody>
<tr>
<th class="center">+</th>
<th class="center internal_border_bottom">0</th>
<th class="center internal_border_bottom">1</th>
<th class="center internal_border_bottom">10</th>
</tr>
<tr>
<td class="center internal_border_right"><strong>0</strong></td>
<td class="center">0</td>
<td class="center grayed">1</td>
<td class="center grayed">10</td>
</tr>
<tr>
<td class="center internal_border_right"><strong>1</strong></td>
<td class="center">1</td>
<td class="center">10</td>
<td class="center grayed">11</td>
</tr>
<tr>
<td class="center internal_border_right"><strong>10</strong></td>
<td class="center">10</td>
<td class="center">11</td>
<td class="center">-</td>
</tr>
</tbody>
</table>
<p>Of the five order-independent facts, two are the same as in decimal (0 + 0 = 0 and 1 + 0 = 1), and one is trivial since it just adds zero (10 + 0 = 10). <strong>This leaves only two facts to memorize: 1 + 1 = 10 and 10 + 1 = 11!</strong></p>
<p>To add two binary numbers, proceed as in decimal addition: </p>
<ul>
<li>If one or both numbers has a fractional part, line up the <a title="Wikipedia article on radix point" href="http://en.wikipedia.org/wiki/Radix_point">radix points</a>.</li>
<li>Proceeding from right to left, add the digits in each &ldquo;column,&rdquo; according to the facts table.</li>
<li>If the result has two-digits, write down the least significant digit; carry the most significant digit to the next column.</li>
</ul>
<p>Let&#8217;s return to the example in the introduction, 1011.01 + 11.011, this time showing it step-by-step:</p>
<div class="wp-caption aligncenter" style="width: 354px"><img src="http://www.exploringbinary.com/wp-content/uploads/BinaryAdditionExampleSteps.png" alt="Steps of Binary Addition" width="344" height="644"/><p class="wp-caption-text">Steps of Binary Addition</p></div>
<p>Eventually you won&#8217;t need to write down the intermediate additions, and you might even start doing &lsquo;1 + 1 + 1&rsquo; as one step.</p>
<h3>Checking the Answer</h3>
<p>You can verify the answer by <a title="Rick Regan's Decimal/Binary Converter" href="http://www.exploringbinary.com/binary-converter/">converting the operands to decimal</a>, doing decimal addition, and then <a title="Rick Regan's Decimal/Binary Converter" href="http://www.exploringbinary.com/binary-converter/">converting the decimal answer to binary</a> (of course you can do it that way period, avoiding binary arithmetic entirely!). 1011.01 = 11.25, and 11.011 = 3.375. They sum to 14.625, which is 1110.101, the answer we got using binary addition.</p>
<h2>Discussion</h2>
<p>We didn&#8217;t need to know the place value of columns, or that a carry represents a power of the base; the algorithm is base-independent. We <em>did</em> however need a base-dependent set of facts, which allowed us to manipulate binary numerals according to the basic rules of binary addition.</p>
<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/binary-addition/">Binary Addition</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.exploringbinary.com/binary-addition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Binary Numbers Haiku</title>
		<link>http://www.exploringbinary.com/binary-numbers-haiku/</link>
		<comments>http://www.exploringbinary.com/binary-numbers-haiku/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 11:45:29 +0000</pubDate>
		<dc:creator>Rick Regan</dc:creator>
				<category><![CDATA[Binary numbers]]></category>

		<guid isPermaLink="false">http://www.exploringbinary.com/?p=337</guid>
		<description><![CDATA[I wrote these haiku about binary numbers: Binary numbers, they are just zeros and ones. Switches &#8212; on and off! The powers of two, nonnegative, negative. Binary numbers. I type in 13. Decimal to binary. 1101. Numbers don&#8217;t add up. IEEE floating-point. Use an epsilon. (Please post your own in the comments.) By Rick Regan [...]<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/binary-numbers-haiku/">Binary Numbers Haiku</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I wrote these <a title="Merriam-Webster Definition of Haiku" href="http://www.merriam-webster.com/dictionary/haiku">haiku</a> about binary numbers:</p>
<div class="haiku">
Binary numbers,<br />
they are just zeros and ones.<br />
Switches &#8212; on and off!
</div>
<p><span id="more-337"></span></p>
<div class="haiku">
<a href="http://www.exploringbinary.com/the-powers-of-two/" title="Read Rick Regan's Article &ldquo;The Powers of Two&rdquo;">The powers of two</a>,<br />
<a title="Read Rick Regan's Article &ldquo;A Table of Nonnegative Powers of Two&rdquo;" href="http://www.exploringbinary.com/a-table-of-nonnegative-powers-of-two/">nonnegative</a>, <a title="Read Rick Regan's Article &ldquo;A Table of Negative Powers of Two&rdquo;" href="http://www.exploringbinary.com/a-table-of-negative-powers-of-two/">negative</a>.<br />
Binary numbers.
</div>
<div class="haiku">
I type in 13.<br />
<a title="Rick Regan's Decimal/Binary Converter" href="http://www.exploringbinary.com/binary-converter/">Decimal to binary</a>.<br />
1101.
</div>
<div class="haiku">
Numbers don&#8217;t add up.<br />
IEEE floating-point.<br />
Use an epsilon.
</div>
<p>(Please post your own in the comments.)</p>
<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/binary-numbers-haiku/">Binary Numbers Haiku</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.exploringbinary.com/binary-numbers-haiku/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How I Taught Third Graders Binary Numbers</title>
		<link>http://www.exploringbinary.com/how-i-taught-third-graders-binary-numbers/</link>
		<comments>http://www.exploringbinary.com/how-i-taught-third-graders-binary-numbers/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 14:51:29 +0000</pubDate>
		<dc:creator>Rick Regan</dc:creator>
				<category><![CDATA[Binary numbers]]></category>
		<category><![CDATA[Binary integers]]></category>
		<category><![CDATA[Convert to binary]]></category>
		<category><![CDATA[Convert to decimal]]></category>
		<category><![CDATA[Education]]></category>

		<guid isPermaLink="false">http://www.exploringbinary.com/?p=335</guid>
		<description><![CDATA[Last week I introduced my son&#8217;s third grade class to binary numbers. I wanted to build on my prior visit, where I introduced them to the powers of two. By teaching them binary, I showed them that place value is not limited to base ten, and that there is a difference between numbers and numerals. [...]<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/how-i-taught-third-graders-binary-numbers/">How I Taught Third Graders Binary Numbers</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Last week I introduced my son&#8217;s third grade class to binary numbers. I wanted to build on my prior visit, where I <a title="Read Rick Regan's Article &ldquo;1,073,741,823 Grains of Rice&rdquo;" href="http://www.exploringbinary.com/1073741823-grains-of-rice/">introduced them to the powers of two</a>. By teaching them binary, I showed them that place value is not limited to base ten, and that there is a difference between numbers and numerals.</p>
<p>My presentation was based on base-ten-block-like imagery, since I knew the students were comfortable expressing numbers with base ten blocks. I thought extending the block model to other bases would work well. I think it did.</p>
<div class="wp-caption aligncenter" style="width: 450px"><img src="http://www.exploringbinary.com/wp-content/uploads/27.binary.whiteboard.png" alt="The Number Twenty-Seven, Broken Into Powers of Two" width="440" height="133"/><p class="wp-caption-text">The Number Twenty-Seven in Tape Flags, Broken Into Powers of Two</p></div>
<p><span id="more-335"></span></p>
<h2>Introduction</h2>
<p>Before my presentation, I put twenty-seven tape flags on the whiteboard, in an unorganized fashion like this:</p>
<div class="wp-caption aligncenter" style="width: 195px"><img src="http://www.exploringbinary.com/wp-content/uploads/27.pile.png" alt="Twenty-Seven Objects" width="185" height="253"/><p class="wp-caption-text">Twenty-Seven Objects</p></div>
<p>(I would have preferred to use magnets instead of tape flags, since they would have been easier to move and align; but I didn&#8217;t have twenty-seven identical magnets.)</p>
<p>I started my presentation by telling the class that I would teach them about something called binary numbers, but that first I would review the numbers they already know &#8212; decimal numbers (I took a moment to explain that this was not the same as &ldquo;decimals&rdquo;). The first thing we did was count the tape flags, and as we counted together I rearranged them into a line:</p>
<div class="wp-caption aligncenter" style="width: 542px"><img src="http://www.exploringbinary.com/wp-content/uploads/27.line.png" alt="Twenty-Seven Objects, Arranged In a Line" width="532" height="67"/><p class="wp-caption-text">Twenty-Seven Objects, Arranged In a Line</p></div>
<p>I asked them how they would write that number. One student came up and wrote &ldquo;27,&rdquo; which is the first answer I expected. Other suggestions were Roman numerals (&ldquo;XXVII&rdquo;) and &ldquo;twenty-seven,&rdquo; also as I anticipated. One student suggested writing it in Japanese (I was expecting a foreign language, but Spanish: &ldquo;veintisiete&rdquo;). Some students suggested arithmetic expressions, like 20 + 7. One unexpected answer was from a girl who wrote it on the board in base ten blocks, which is how I was planning to rearrange the tape flags next!</p>
<p>I suggested tally marks as another alternative, and wrote twenty-seven in tally marks on the board.</p>
<h2>Decimal</h2>
<p>I singled-out the answer &ldquo;27&rdquo; and said it is written in place value. I reviewed how the places were powers of ten. Then, as the class counted along to twenty-seven, I rearranged the flags into base ten block powers of ten groups, under headings labeled &ldquo;tens&rdquo; and &ldquo;ones&rdquo;:</p>
<div class="wp-caption aligncenter" style="width: 182px"><img src="http://www.exploringbinary.com/wp-content/uploads/27.decimal.png" alt="Twenty-Seven Objects, Broken Into Powers of Ten" width="172" height="352"/><p class="wp-caption-text">Twenty-Seven Objects, Broken Into Powers of Ten</p></div>
<p>We counted the powers of ten and wrote the totals in the blanks I drew below each grouping of blocks; we came up with the numeral &ldquo;27&rdquo;: two tens and seven ones.</p>
<h2>Quinary</h2>
<p>I told the class that place value is not limited to base ten. I said, for example, you could write any number in base five, or quinary. (I wanted to take an intermediate step to binary, which is the simplest base, having only a maximum of one instance of each power.) I had them compute the powers of five from one to 625, and I explained that these are the places in quinary. I told them we would group the flags into powers of five. I wrote three headings on the board: &ldquo;twenty-fives,&rdquo; &ldquo;fives,&rdquo; and &ldquo;ones.&rdquo;</p>
<p>I asked &ldquo;are there any twenty-fives in twenty-seven&rdquo; and they said &ldquo;yes.&rdquo; We then counted out twenty-five flags, which I removed from the decimal grouping we&#8217;d just done.  I built a block as we went, under the twenty-five label. Next I asked if there were any more twenty-fives in the flags that remained, and they quickly said &ldquo;no.&rdquo; They could also see there were no fives, and that there were only two ones left, which I moved under the ones label.</p>
<div class="wp-caption aligncenter" style="width: 337px"><img src="http://www.exploringbinary.com/wp-content/uploads/27.quinary.png" alt="Twenty-Seven Objects, Broken Into Powers of Five" width="327" height="251"/><p class="wp-caption-text">Twenty-Seven Objects, Broken Into Powers of Five</p></div>
<p>We counted the powers of five and wrote them under each grouping of blocks, coming up with the numeral &ldquo;102&rdquo;: one twenty-five, zero fives, and two ones. Some kids wanted to pronounce this as &ldquo;one-hundred and two&rdquo;, but I told them you pronounce it as &ldquo;twenty-seven,&rdquo; or &ldquo;one-zero-two base five.&rdquo;</p>
<h2>Binary</h2>
<p>Now I said let&#8217;s look at another example of place value: base two, or binary. I said it is based on <a title="Read Rick Regan's Article &ldquo;A Table of Nonnegative Powers of Two&rdquo;" href="http://www.exploringbinary.com/a-table-of-nonnegative-powers-of-two/">powers of two</a>. We computed the powers of two from one to thirty-two (my son was rattling them off to 4096 before I could cut him off <img src='http://www.exploringbinary.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ), which they remembered from <a title="Read Rick Regan's Article &ldquo;1,073,741,823 Grains of Rice&rdquo;" href="http://www.exploringbinary.com/1073741823-grains-of-rice/">my last visit</a>.</p>
<p>We proceeded as above, except we pulled out the powers of two (from the flags in the quinary grouping): first we looked for sixteens, then eights, then fours, then twos, and then ones.</p>
<div class="wp-caption aligncenter" style="width: 380px"><img src="http://www.exploringbinary.com/wp-content/uploads/27.binary.png" alt="Twenty-Seven Objects, Broken Into Powers of Two" width="370" height="206"/><p class="wp-caption-text">Twenty-Seven Objects, Broken Into Powers of Two</p></div>
<p>We counted the powers of two and wrote them under each label, coming up with the numeral “11011”: one sixteen, one eight, zero fours, one two, and one one.</p>
<h2>Number of Digits</h2>
<p>When I was done with the tape flag examples, I took a moment to explain that base ten has ten digits, base five has five digits, and base two has two digits. As an example, I said that in base ten you could never have a 10 in any place, because that would be the same as a 1 in the next higher place. Similarly for base two, a 2 in a place would equal the next higher power of two, which also would be the same as a 1 in the next higher place.</p>
<h2>Other Bases</h2>
<p>I told the class that you could write any whole number in any base. One kid asked if I could do it in a base that was greater than ten (I forget which base he used as an example). I said any number could be the base, but you&#8217;d have to have enough symbols. I briefly explained why you wouldn&#8217;t want a multi-digit number in a place (it would make the numeral ambiguous). I mentioned base sixteen, and said it uses the letters A through F for the values ten through fifteen. (I did not intend to get into hexadecimal, but hey, I wanted to answer the question!)</p>
<h2>Students as Binary Numbers</h2>
<p>At the front of the classroom, just below the whiteboard, I arranged five chairs, facing the class. I wrote the names of the binary places above the chairs, left to right from the class&#8217;s point of view: sixteens, eights, fours, twos, ones. I got five volunteers to come up, and said that I would turn them into a binary number. I said if I told them to sit in their chair, they would count as a 0; if I told them to stand in front of their chair, they would count as a 1.</p>
<p>For my first example, I put the students in the pattern 11011, which the class correctly read as twenty-seven (they added the place values above the chairs of the standing students &#8212; that or they read the numerals I had left on the board under the tape flags <img src='http://www.exploringbinary.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ). I did a few other examples like this, which amounted to binary to decimal conversion. They got them all right.</p>
<p>Next I did what amounted to decimal to binary conversion, asking the class how to arrange the volunteers to represent a given number. For example, when I said &ldquo;nine,&rdquo; they called out instructions to make the volunteers stand and sit to make the pattern 1001. They got all of these examples correct as well.</p>
<h2>Binary Counting</h2>
<p>The above discussion took about twenty-five minutes, so with the extra five minutes I squeezed in a demonstration of a binary counter. I took a new set of five volunteers and had the class direct them through the sequence zero to thirty-one. We got through the count, but I think a few students got lost as some of the faster adders called out instructions. In any case, there were definitely some who understood the process, enough to know that when I asked them to display thirty-two, they said we would need another volunteer.</p>
<p>If I had more time, I would have done the count a second time, with the volunteers driving the counting; I came up with this scheme after I left the class:</p>
<ul>
<li>All volunteers start out sitting, representing zero.</li>
<li>Whenever I say &ldquo;count&rdquo;
<ul>
<li>The ones place volunteer does the opposite of what she is currently doing: if she&#8217;s sitting, she stands; if she&#8217;s standing, she sits.</li>
<li>For everyone not in the ones place, if the kid to your left sits, you do the opposite of what you&#8217;re currently doing.</li>
</ul>
</li>
</ul>
<p>I think this would have made the counting easier and more fun.</p>
<h2>Binary Fractions</h2>
<p>I mentioned briefly that there is an equivalent of decimals in binary numbers. Instead of the tenths, hundredths, etc. places there are the halves, quarters, eighths, etc. places.</p>
<h2>Discussion</h2>
<p>I think most of the kids understood the presentation; certainly, they were all engaged. I&#8217;d like to think it gave them a better understanding of decimal, even if they didn&#8217;t understand the details of binary. I told them &ldquo;you may not understand this now, but when you see it again someday, you&#8217;ll remember back to this day in third grade and it will come to you.&rdquo; Someone then asked what grade they teach this in. I said it&#8217;s not really part of any particular math class (as far as I know) but that they would be taught it in a high-school computer class if they took one.</p>
<p>I used number words when I wanted to avoid decimal numerals; for example, when describing a number or when labeling places. Unfortunately, number words have decimal place value built-in, but that&#8217;s the closest I know how to get to a base-independent description of a number. That said, I don&#8217;t think the class recognized this, so I don&#8217;t think it caused any confusion.</p>
<p>I didn&#8217;t explain why we broke the numbers down by starting with the largest powers and working down. If I had more time, maybe I would have let them discover the algorithm themselves.</p>
<p>I use the term &ldquo;number&rdquo; when I really mean &ldquo;numeral&rdquo;, as in &ldquo;binary number&rdquo; or &ldquo;decimal number.&rdquo; This terminology is unfortunate, but it is standard.</p>
<h2>References</h2>
<ul>
<li><a title="See Rick Garlikov's article on the use of the Socratic method to teach binary numbers to third graders" href="http://www.garlikov.com/Soc_Meth.html">Rick Garlikov&#8217;s use of the Socratic method to teach binary numbers to third graders</a>.
<p>I used a different approach, but a lot of the same concepts are involved. Rick&#8217;s method centered on binary counting, which lead to a discussion of powers and places. My method started with powers and places, and lead to binary numerals and then binary counting. Rick discussed other bases after discussing binary, whereas I discussed them before. Also, he discussed binary arithmetic, but I did not.</p>
<p>One thing I liked about my approach is that I built in the concept of base conversion, showing the equivalence of whole numbers written in any base. I also liked the way I exhibited the concept of &ldquo;number vs. numeration.&rdquo;</p>
</li>
<li><a title="See CS Unplugged Page on Binary Numbers" href="http://csunplugged.org/binary-numbers">Computer Science Unplugged Page on Binary Numbers</a>.
<p>This page contains videos on binary counting, which inspired my own binary counting demonstration.</p>
</li>
<li>My article &ldquo;<a title="Read Rick Regan's Article &ldquo;How I Taught My Mother Binary Numbers&rdquo;" href="http://www.exploringbinary.com/how-i-taught-my-mother-binary-numbers/">How I Taught My Mother Binary Numbers</a>.&rdquo;
<p>I taught my mother a little differently (at least in my second attempt), mainly because I think most adults don&#8217;t think explicitly about place value.</p>
</li>
</ul>
<h2>Please Try This</h2>
<p>I&#8217;d love to know if this method works for you; if you try it, please let me know!</p>
<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/how-i-taught-third-graders-binary-numbers/">How I Taught Third Graders Binary Numbers</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.exploringbinary.com/how-i-taught-third-graders-binary-numbers/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>In Search of Decimal/Binary/Hexadecimal Palindromes</title>
		<link>http://www.exploringbinary.com/in-search-of-decimal-binary-hexadecimal-palindromes/</link>
		<comments>http://www.exploringbinary.com/in-search-of-decimal-binary-hexadecimal-palindromes/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 15:33:17 +0000</pubDate>
		<dc:creator>Rick Regan</dc:creator>
				<category><![CDATA[Binary numbers]]></category>

		<guid isPermaLink="false">http://www.exploringbinary.com/?p=279</guid>
		<description><![CDATA[Are there any multiple digit hexadecimal number palindromes that are also palindromic in binary and decimal? I have been searching but have not found any. I started my search with my program that finds multiple-base palindromes. I generated palindromes in binary, and then checked them to see if they were also palindromes in hexadecimal and [...]<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/in-search-of-decimal-binary-hexadecimal-palindromes/">In Search of Decimal/Binary/Hexadecimal Palindromes</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Are there any multiple digit hexadecimal number palindromes that are also palindromic in binary and decimal? I have been searching but have not found any.</p>
<p>I started my search with my <a href="http://www.exploringbinary.com/finding-numbers-that-are-palindromic-in-multiple-bases/" title="Read Rick Regan's Article &ldquo;Finding Numbers That Are Palindromic In Multiple Bases&rdquo;">program that finds multiple-base palindromes</a>. I generated palindromes in binary, and then checked them to see if they were also palindromes in hexadecimal and decimal. I looked for decimal/binary/hexadecimal palindromes up to 16 hex digits long, but did not find any.</p>
<p>To continue my search into bigger numbers, I wrote a program that uses arbitrary-precision integer arithmetic and a more efficient algorithm. Despite being able to search much further, I still have not found any.</p>
<p>In this article, I&#8217;ll analyze the size of the palindrome &ldquo;search space&rdquo;, explain my improved algorithm, and discuss the state of my search.</p>
<p><span id="more-279"></span></p>
<h2>Search Space for Decimal/Binary/Hexadecimal Palindromes</h2>
<p>The biggest obstacle in the search for palindromes is the growth in the amount of numbers that must be checked &#8212; the <em>search space</em>. As the number of digits increases, the search space grows exponentially. While this exponential growth can&#8217;t be eliminated, it can be delayed &#8212; by pruning the search space.</p>
<p>Consider the search space for 32 hexadecimal digit decimal/binary/hexadecimal palindromes. With no pruning, 15&middot;16<sup>31</sup> integers would have to be checked &#8212; 319,014,718,988,379,809,496,913,694,467,282,698,240 numbers, an impossible task. If only hexadecimal palindromes are considered, the search space is reduced to <a href="http://www.exploringbinary.com/counting-binary-and-hexadecimal-palindromes/" title="Read Rick Regan's Article &ldquo;Counting Binary and Hexadecimal Palindromes&rdquo;"> 15&middot;16<sup>15</sup></a> = 17,293,822,569,102,704,640 numbers &#8212; much smaller but still intractable. If only <a href="http://www.exploringbinary.com/the-structure-of-binary-hexadecimal-palindromes/" title="Read Rick Regan's Article &ldquo;The Structure of Binary/Hexadecimal Palindromes&rdquo;">binary/hexadecimal palindromes</a> are considered, then there are <a href="http://www.exploringbinary.com/counting-binary-hexadecimal-palindromes/" title="Read Rick Regan's Article &ldquo;Counting Binary/Hexadecimal Palindromes&rdquo;">2<sup>16</sup> + 2<sup>32</sup></a> = 4,295,032,832 numbers to be checked &#8212; quite manageable!</p>
<p>The binary/hexadecimal palindrome space can be partitioned by starting digit so that subsets can be searched independently. Consider the 32 hexadecimal digit binary/hexadecimal palindromes. There are <a href="http://www.exploringbinary.com/counting-binary-hexadecimal-palindromes/" title="Read Rick Regan's Article &ldquo;Counting Binary/Hexadecimal Palindromes&rdquo;">2<sup>16</sup></a> = 65,536 that begin with the digits 1 and 3, and <a href="http://www.exploringbinary.com/counting-binary-hexadecimal-palindromes/" title="Read Rick Regan's Article &ldquo;Counting Binary/Hexadecimal Palindromes&rdquo;">2<sup>32</sup></a> = 4,294,967,296 that begin with the digits 5, 7, 9, and F. The number of palindromes that start with 1 and 3 is markedly lower, allowing for a deeper search within them.</p>
<p>The following diagrams illustrate how the search space grows, showing the search spaces for the 16, 32, and 64 digit hexadecimal palindromes:</p>
<div class="wp-caption aligncenter" style="width: 470px"><img src="http://www.exploringbinary.com/wp-content/uploads/bin-hex-search-space.16.png" alt="Number of 16-Digit Hexadecimal Palindromes, by Subset (not to scale)" width="460" height="273"/><p class="wp-caption-text">Number of 16-Digit Hexadecimal Palindromes, by Subset (<strong>not to scale</strong>)</p></div>
<div class="wp-caption aligncenter" style="width: 471px"><img src="http://www.exploringbinary.com/wp-content/uploads/bin-hex-search-space.32.png" alt="Number of 32-Digit Hexadecimal Palindromes, by Subset (not to scale)" width="461" height="271"/><p class="wp-caption-text">Number of 32-Digit Hexadecimal Palindromes, by Subset (<strong>not to scale</strong>)</p></div>
<div class="wp-caption aligncenter" style="width: 468px"><img src="http://www.exploringbinary.com/wp-content/uploads/bin-hex-search-space.64.png" alt="Number of 64-Digit Hexadecimal Palindromes, by Subset (not to scale)" width="458" height="274"/><p class="wp-caption-text">Number of 64-Digit Hexadecimal Palindromes, by Subset (<strong>not to scale</strong>)</p></div>
<h2>Program to Find Decimal/Binary/Hexadecimal Palindromes</h2>
<p>I wrote a C program to search for decimal/binary/hexadecimal palindromes &#8212; it is based on two things:</p>
<ul>
<li><strong>Arbitrary-precision integers</strong>.
<p>This allows for palindrome numbers that are too big to fit in an <em>unsigned long long</em> integer variable; that is, numbers bigger than 64 bits, or 16 hex digits. I used <a href="http://www.exploringbinary.com/how-to-install-and-run-gmp-on-windows-using-mpir/" title="Read Rick Regan's Article &ldquo;How to Install and Run GMP on Windows Using MPIR&rdquo;">GMP in Visual C++ on Windows</a>.</p>
</li>
<li><strong>Direct generation of binary/hexadecimal palindromes</strong>.
<p>This reduces the search space dramatically, so that only known binary/hexadecimal palindromes are checked &#8212; for being palindromic in decimal. I used a simple algorithm derived from my <a href="http://www.exploringbinary.com/the-structure-of-binary-hexadecimal-palindromes/" title="Read Rick Regan's Article &ldquo;The Structure of Binary/Hexadecimal Palindromes&rdquo;">analysis of binary/hexadecimal palindromes</a>.</p>
</li>
</ul>
<p>I will outline the algorithm instead of providing the source code.</p>
<h3>The Algorithm</h3>
<p>Binary/hexadecimal palindromes could be generated in two ways. One way would be incrementally, by generating the two-digit palindromes, then the three-digit palindromes, then the four-digit palindromes, etc. A set of m-digit palindromes would be built from a set of m-1 digit palindromes, by inserting a digit in the middle of each m-1 digit palindrome. This requires storage of palindromes, which will not scale &#8212; the number of palindromes grows exponentially.</p>
<p>Another way to generate binary/hexadecimal palindromes &#8212; the way I chose &#8212; is to construct them from permutations of hex digits. Each of the six subsets of binary/hexadecimal palindromes has its own rules for valid digits:</p>
<ul>
<li>Starts/ends with 1: each digit between can be 0 or 1</li>
<li>Starts/ends with 3: each digit between can be 0 or 3</li>
<li>Starts/ends with 5: each digit between can be 0, 2, 5, or 7</li>
<li>Starts/ends with 7: each digit between can be 0, 2, 5, or 7</li>
<li>Starts/ends with 9: each digit between can be 0, 6, 9, or F</li>
<li>Starts/ends with F: each digit between can be 0, 6, 9, or F</li>
</ul>
<p>You construct palindromes of n digits from permutations of floor(n/2) digits. For example, to generate a 32 digit palindrome that starts with 5, create a number that starts with 5 followed by a 15 digit permutation of the digits 0, 2, 5, and 7. Then, reverse that number and append it to itself to create a 32 digit palindrome. (The process for odd length palindromes is similar, except you insert an extra middle digit between the two halves.)</p>
<p>Permutations are easily generated, with a series of nested loops. You can nest loops statically, by coding a loop for each place of the permutation, or you can nest them dynamically, by calling a single loop recursively. The advantage of dynamic nesting is not having to add loops manually for increasing digit lengths; the advantage of static nesting is the ability to &ldquo;checkpoint&rdquo; the state of the search easily &#8212; an important feature for long running programs. I chose static nesting for that reason.</p>
<h2>Results</h2>
<p>I&#8217;ve searched the &ldquo;1/3 space&rdquo; through all 64 hex digit numbers, and the  &ldquo;5/7/9/F space&rdquo; through all 32 hex digit numbers. I have not found a single multi-digit decimal/binary/hexadecimal palindrome. </p>
<p>I have suspended my search, since the running time of my program is starting to explode. For example, it took almost 60 hours on my Intel Core Duo processor to test all 2<sup>32</sup> 64 hex digit binary/hexadecimal palindromes in the 1/3 space. Resuming the search would probably require a <a href="http://www.mersenne.org/" title="Home page of GIMPS, the Great Internet Mersenne Prime Search">GIMPS</a>-like distributive computing approach, which I have no plans to undertake.</p>
<h2>Discussion</h2>
<p>Are there any tricks to reduce the search space further, delaying the inevitable exponential explosion even more? <a title="Charlton's Binary/Decimal Palindrome Page" href="http://bach.dynet.com/palin/">Charlton&#8217;s binary/decimal palindrome search algorithm</a> eliminates swaths of numbers as it runs, recognizing conditions under which copalindromic numbers can&#8217;t exist. Can similar ideas be applied to the search for decimal/binary/hexadecimal palindromes?</p>
<h3>Another Way to Count Binary/Hexadecimal Palindromes</h3>
<p>In my article &ldquo;<a href="http://www.exploringbinary.com/counting-binary-hexadecimal-palindromes/" title="Read Rick Regan's Article &ldquo;Counting Binary/Hexadecimal Palindromes&rdquo;">Counting Binary/Hexadecimal Palindromes</a>&rdquo; I derived formulas to count binary/hexadecimal palindromes using geometric series. An alternate way would be based on counting permutations. For example, the number of 32 digit palindromes starting with 5 is the number of 15 digit permutations of the digits 0, 2, 5, and 7; that is, 4<sup>15</sup> =  2<sup>30</sup> = 1,073,741,824.</p>
<p>(You would still need geometric series to count the number of palindromes of <em>n-digits or less</em>.)</p>
<h2>Are There Any?</h2>
<p>Are there any decimal/binary/hexadecimal palindromes? Can it be proved either way?</p>
<p>I have no reason to believe they don&#8217;t exist. After all, <a href="http://www.exploringbinary.com/finding-numbers-that-are-palindromic-in-multiple-bases/" title="Read Rick Regan's Article &ldquo;Finding Numbers That Are Palindromic In Multiple Bases&rdquo;">there are at least two multi-digit decimal/binary/octal palindromes</a>. And it&#8217;s always possible I made an error in my search, although <a title="Charlton's Binary/Decimal Palindrome Page" href="http://bach.dynet.com/palin/">Charlton&#8217;s results</a> confirm my results through 32 hex digits plus.</p>
<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/in-search-of-decimal-binary-hexadecimal-palindromes/">In Search of Decimal/Binary/Hexadecimal Palindromes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.exploringbinary.com/in-search-of-decimal-binary-hexadecimal-palindromes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Counting Binary/Hexadecimal Palindromes</title>
		<link>http://www.exploringbinary.com/counting-binary-hexadecimal-palindromes/</link>
		<comments>http://www.exploringbinary.com/counting-binary-hexadecimal-palindromes/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 17:06:25 +0000</pubDate>
		<dc:creator>Rick Regan</dc:creator>
				<category><![CDATA[Binary numbers]]></category>
		<category><![CDATA[Algebra]]></category>
		<category><![CDATA[Exponents]]></category>
		<category><![CDATA[Geometric series]]></category>
		<category><![CDATA[Proof]]></category>

		<guid isPermaLink="false">http://www.exploringbinary.com/?p=272</guid>
		<description><![CDATA[In my article &#8220;Counting Binary and Hexadecimal Palindromes&#8221; I derived formulas for counting binary palindromes and hexadecimal palindromes. For each type of palindrome, I derived two pairs of formulas: one pair to count n-digit palindromes, and one pair to count palindromes of n digits or less. In this article, I will derive similar formulas to [...]<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/counting-binary-hexadecimal-palindromes/">Counting Binary/Hexadecimal Palindromes</a></p>
]]></description>
			<content:encoded><![CDATA[<p>In my article <a href="http://www.exploringbinary.com/counting-binary-and-hexadecimal-palindromes/" title="Read Rick Regan's Article &ldquo;Counting Binary and Hexadecimal Palindromes&rdquo;">&ldquo;Counting Binary and Hexadecimal Palindromes&rdquo;</a> I derived formulas for counting binary palindromes and hexadecimal palindromes. For each type of palindrome, I derived two pairs of formulas: one pair to count n-digit palindromes, and one pair to count palindromes of n digits or less.</p>
<p>In this article, I will derive similar formulas to count binary/hexadecimal palindromes &#8212; <a href="http://www.exploringbinary.com/the-structure-of-binary-hexadecimal-palindromes/" title="Read Rick Regan's Article &ldquo;The Structure of Binary/Hexadecimal Palindromes&rdquo;">multi-base palindromes I&#8217;ve shown to have an algorithmically defined structure</a>.</p>
<p><span id="more-272"></span></p>
<h2>Binary/Hexadecimal Palindromes of n Hexadecimal Digits</h2>
<p>To derive the formula to count binary/hexadecimal palindromes, look at the tables in my article <a href="http://www.exploringbinary.com/the-structure-of-binary-hexadecimal-palindromes/" title="Read Rick Regan's Article &ldquo;The Structure of Binary/Hexadecimal Palindromes&rdquo;">&ldquo;The Structure of Binary/Hexadecimal Palindromes&rdquo;</a>. There&#8217;s a table of palindromes for each starting hexadecimal digit: 1, 3, 5, 7, 9, and F. Each table lists the binary/hexadecimal palindromes of one to five hex digits, for each starting digit. If you count the palindromes in the tables &#8212; and continue the pattern beyond five digits &#8212; this is what you&#8217;ll get:</p>
<table class="center" border="1" summary="Counts of nonzero, n hex digit binary/hexadecimal palindromes">
<caption><strong>Counts of Nonzero, n Hex Digit Binary/Hexadecimal Palindromes</strong></caption>
<tbody>
<tr>
<th class="center">Starting Hex Digit</th>
<th class="center">Count From n=1 &#8230; </th>
</tr>
<tr>
<td class="left">1</td>
<td class="left">1, 1, 2, 2, 4, 4, 8, 8, &#8230;</td>
</tr>
<tr>
<td class="left">3</td>
<td class="left">1, 1, 2, 2, 4, 4, 8, 8, &#8230;</td>
</tr>
<tr>
<td class="left">5</td>
<td class="left">1, 1, 4, 4, 16, 16, 64, 64, &#8230;</td>
</tr>
<tr>
<td class="left">7</td>
<td class="left">1, 1, 4, 4, 16, 16, 64, 64, &#8230;</td>
</tr>
<tr>
<td class="left">9</td>
<td class="left">1, 1, 4, 4, 16, 16, 64, 64, &#8230;</td>
</tr>
<tr>
<td class="left">F</td>
<td class="left">1, 1, 4, 4, 16, 16, 64, 64, &#8230;</td>
</tr>
</tbody>
</table>
<p>This pattern continues forever, based on the structure of the palindromes.</p>
<p>(Notice we&#8217;re not counting 0 as a palindrome &#8212; if you want to, add 1 to the formulas we derive below.)</p>
<p>There are two different count sequences: one of interleaved nonnegative powers of two, and one of interleaved nonnegative powers of four. As we learned when <a href="http://www.exploringbinary.com/counting-binary-and-hexadecimal-palindromes/" title="Read Rick Regan's Article &ldquo;Counting Binary and Hexadecimal Palindromes&rdquo;">counting n-digit binary palindromes</a>, the sequence of interleaved nonnegative powers of two is captured by these two formulas:</p>
<ul>
<li>When n is even: 2<sup>n/2-1</sup></li>
<li>When n is odd: 2<sup>(n+1)/2-1</sup></li>
</ul>
<p>Those two formulas apply to the starting hex digits 1 and 3, counting the number of n hex digit binary/hexadecimal palindromes for each.</p>
<p>You can use similar formulas to generate the sequence of interleaved nonnegative powers of four:</p>
<ul>
<li>When n is even: 4<sup>n/2-1</sup> = 2<sup>2&middot;(n/2-1)</sup> = 2<sup>n-2</sup></li>
<li>When n is odd: 4<sup>(n+1)/2-1</sup> = 2<sup>2&middot;((n+1)/2-1)</sup> = 2<sup>n-1</sup></li>
</ul>
<p>(It should not be surprising that these expressions simplify to powers of two &#8212; powers of four are powers of two.)</p>
<p>Those two formulas apply to the starting hex digits 5, 7, 9, and F, counting the number of n hex digit binary/hexadecimal palindromes for each.</p>
<h3>Combining the Formulas</h3>
<p>The formulas above count the number of n hex digit binary/hexadecimal palindromes by starting hex digit. We can combine them into one pair of formulas that counts <em>all</em> n hex digit binary/hexadecimal palindromes, by adding two copies of the first pair of formulas to four copies of the second pair:</p>
<ul>
<li>When n is even: 2&middot;2<sup>n/2-1</sup> + 4&middot;2<sup>n-2</sup> = <span class="highlight_theme_blue_box">2<sup>n/2</sup> + 2<sup>n</sup></span></li>
<li>When n is odd: 2&middot;2<sup>(n+1)/2-1</sup> + 4&middot;2<sup>n-1</sup> = <span class="highlight_theme_blue_box">2<sup>(n+1)/2</sup> + 2<sup>n+1</sup></span></li>
</ul>
<h2>Binary/Hexadecimal Palindromes of n Hexadecimal Digits or Less</h2>
<p>To compute the total number of binary/hexadecimal palindromes of n hex digits or less, we need to add together the count of palindromes for each number of digits, 1 through n. We could create a series using the pair of formulas above, but it&#8217;s easier to start from scratch: we&#8217;ll create a series for each starting digit, and then add them together. </p>
<p>The count of palindromes for each starting digit, from 1 to n digits, is an interleaved sequence &#8212; either of nonnegative powers of two or nonnegative powers of four. If you separate those sequences and add their terms &#8212; creating series &#8212; you&#8217;ll have these building blocks, which I&#8217;ll use to derive a formula:</p>
<ul>
<li>The sum of the first m nonnegative powers of two: <img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/counting-binary-hexadecimal-palindromes/a7caf098e64f4c7cefae4ba5d99311a9.png' alt='\mbox{\footnotesize{\displaystyle{\sum_{i=0}^{m-1}2^i}}}'/> = 2<sup>m</sup> &#8211; 1 .</li>
<li>The sum of the first m nonnegative powers of four: <img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/counting-binary-hexadecimal-palindromes/c2a59ba17783d30b33957beaa8158c36.png' alt='\mbox{\footnotesize{\displaystyle{\sum_{i=0}^{m-1}4^i}}}'/> = (4<sup>m</sup> &#8211; 1)/3 .</li>
</ul>
<p>We can use these expressions for each of the interleaved series, adding them together to get expressions that count palindromes of n digits or less by starting digit. We can then combine <em>those</em> expressions to get one pair of formulas &#8212; one that counts <em>all</em> palindromes of n digits or less.</p>
<h3>Total Palindromes for Each of the Starting Digits 1 and 3</h3>
<ul>
<li><strong>The number of digits n is even</strong>
<p>The sum consists of two identical series of n/2 terms each:</p>
<p><img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/counting-binary-hexadecimal-palindromes/759a5a69c86e49a3f5a72accf5d77b49.png' alt='\mbox{\footnotesize{\displaystyle{\sum_{i=0}^{\frac{n}{2}-1}2^i}}}'/> = 2<sup>n/2</sup> &#8211; 1.</p>
<p>Added together, they are <strong>2(2<sup>n/2</sup> &#8211; 1)</strong>.</p>
</li>
<li><strong>The number of digits n is odd</strong>
<p>The sum consists of two identical series of (n-1)/2 terms each, plus an extra term. Each series looks like this:</p>
<p><img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/counting-binary-hexadecimal-palindromes/e1b7237ca73f62e78f9e3fb5b0c376f0.png' alt='\mbox{\footnotesize{\displaystyle{\sum_{i=0}^{\frac{n-1}{2}-1}2^i}}}'/> = 2<sup>(n-1)/2</sup> &#8211; 1.</p>
<p>Added together, they are 2&middot;(2<sup>(n-1)/2</sup> &#8211; 1).</p>
<p>The extra term is 2<sup>(n-1)/2</sup>, what would have been the next term in one of the series. Adding this to the two series we get 2(2<sup>(n-1)/2</sup> &#8211; 1) + 2<sup>(n-1)/2</sup>, which simplifies to <strong>3&middot;2<sup>(n-1)/2</sup> &#8211; 2</strong>.</p>
</li>
</ul>
<h3>Total Palindromes for Each of the Starting Digits 5, 7, 9, and F</h3>
<ul>
<li><strong>The number of digits n is even</strong>
<p>The sum consists of two identical series of n/2 terms each:</p>
<p><img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/counting-binary-hexadecimal-palindromes/7c0351dcd3dd141b39ee9ac4f1f5d941.png' alt='\mbox{\footnotesize{\displaystyle{\sum_{i=0}^{\frac{n}{2}-1}4^i}}}'/> = (4<sup>n/2</sup> &#8211; 1)/3.</p>
<p>Added together, they are <strong>2&middot;(4<sup>n/2</sup> &#8211; 1)/3</strong>.</p>
</li>
<li><strong>The number of digits n is odd</strong>
<p>The sum consists of two identical series of (n-1)/2 terms each, plus an extra term. Each series looks like this:</p>
<p><img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/counting-binary-hexadecimal-palindromes/70de5e7f1b0c74eec45c0ce2ed8e469e.png' alt='\mbox{\footnotesize{\displaystyle{\sum_{i=0}^{\frac{n-1}{2}-1}4^i}}}'/> =  (4<sup>(n-1)/2</sup> &#8211; 1)/3.</p>
<p>Added together, they are 2&middot;(4<sup>(n-1)/2</sup> &#8211; 1)/3.</p>
<p>The extra term is 4<sup>(n-1)/2</sup>, what would have been the next term in one of the series. Adding this to the two series we get 2(4<sup>(n-1)/2</sup> &#8211; 1)/3 + 4<sup>(n-1)/2</sup>, which simplifies to <strong>(5&middot;4<sup>(n-1)/2</sup> &#8211; 2)/3</strong>.</p>
</li>
</ul>
<h3>Total Palindromes for All Digits</h3>
<p>To get the total palindromes of n digits or less, we add two copies of the &ldquo;1/3&rdquo; pair of formulas to four copies of the &ldquo;5/7/9/F&rdquo; pair of formulas:</p>
<ul>
<li><strong>The number of digits n is even</strong>
<p>2(2(2<sup>n/2</sup> &#8211; 1)) + 4(2(4<sup>n/2</sup> &#8211; 1)/3) = <span class="highlight_theme_blue_box">4(2<sup>n/2</sup> &#8211; 1) + 8(2<sup>n</sup> &#8211; 1)/3</span></p>
</li>
<li><strong>The number of digits n is odd</strong>
<p>2(3&middot;2<sup>(n-1)/2</sup> &#8211; 2) + 4((5&middot;4<sup>(n-1)/2</sup> &#8211; 2)/3) = <span class="highlight_theme_blue_box">2(3&middot;2<sup>(n-1)/2</sup> &#8211; 2) + 4(5&middot;2<sup>n-1</sup> &#8211; 2)/3</span></p>
</li>
</ul>
<h2>Summary</h2>
<p>Here is a summary of the binary/hexadecimal palindrome counting formulas:</p>
<table class="center" border="1" summary="Summary of binary/hexadecimal nonzero palindrome counting formulas">
<caption><strong>Nonzero Binary/Hexadecimal Palindrome Counting Formulas</strong></caption>
<tbody>
<tr>
<th class="center">Num Hex Digits</th>
<th class="center">Even n</th>
<th class="center">Odd n</th>
</tr>
<tr>
<td class="left">n</td>
<td class="center">2<sup>n/2</sup> + 2<sup>n</sup></td>
<td class="center">2<sup>(n+1)/2</sup> + 2<sup>n+1</sup></td>
</tr>
<tr>
<td class="left">n or less</td>
<td class="center">4(2<sup>n/2</sup> &#8211; 1) + 8(2<sup>n</sup> &#8211; 1)/3</td>
<td class="center">2(3&middot;2<sup>(n-1)/2</sup> &#8211; 2) + 4(5&middot;2<sup>n-1</sup> &#8211; 2)/3</td>
</tr>
</tbody>
</table>
<p class="break">Here&#8217;s a table listing the values of these formulas for n = 1 to 16:</p>
<table class="center" border="1" summary="All nonzero 1 through 16 hex digit binary/hexadecimal palindromes">
<caption><strong>1-16 Hex Digit Binary/Hexadecimal Palindromes (not counting 0)</strong></caption>
<tbody>
<tr>
<th class="center">Num Hex Digits (n)</th>
<th class="center">Num n-digit Palindromes</th>
<th class="center">Total Palindromes</th>
</tr>
<tr>
<td class="left">1</td>
<td class="center">6</td>
<td class="center">6</td>
</tr>
<tr>
<td class="left">2</td>
<td class="center">6</td>
<td class="center">12</td>
</tr>
<tr>
<td class="left">3</td>
<td class="center">20</td>
<td class="center">32</td>
</tr>
<tr>
<td class="left">4</td>
<td class="center">20</td>
<td class="center">52</td>
</tr>
<tr>
<td class="left">5</td>
<td class="center">72</td>
<td class="center">124</td>
</tr>
<tr>
<td class="left">6</td>
<td class="center">72</td>
<td class="center">196</td>
</tr>
<tr>
<td class="left">7</td>
<td class="center">272</td>
<td class="center">468</td>
</tr>
<tr>
<td class="left">8</td>
<td class="center">272</td>
<td class="center">740</td>
</tr>
<tr>
<td class="left">9</td>
<td class="center">1056</td>
<td class="center">1796</td>
</tr>
<tr>
<td class="left">10</td>
<td class="center">1056</td>
<td class="center">2852</td>
</tr>
<tr>
<td class="left">11</td>
<td class="center">4160</td>
<td class="center">7012</td>
</tr>
<tr>
<td class="left">12</td>
<td class="center">4160</td>
<td class="center">11172</td>
</tr>
<tr>
<td class="left">13</td>
<td class="center">16512</td>
<td class="center">27684</td>
</tr>
<tr>
<td class="left">14</td>
<td class="center">16512</td>
<td class="center">44196</td>
</tr>
<tr>
<td class="left">15</td>
<td class="center">65792</td>
<td class="center">109988</td>
</tr>
<tr>
<td class="left">16</td>
<td class="center">65792</td>
<td class="center">175780</td>
</tr>
</tbody>
</table>
<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/counting-binary-hexadecimal-palindromes/">Counting Binary/Hexadecimal Palindromes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.exploringbinary.com/counting-binary-hexadecimal-palindromes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Structure of Binary/Hexadecimal Palindromes</title>
		<link>http://www.exploringbinary.com/the-structure-of-binary-hexadecimal-palindromes/</link>
		<comments>http://www.exploringbinary.com/the-structure-of-binary-hexadecimal-palindromes/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 16:57:14 +0000</pubDate>
		<dc:creator>Rick Regan</dc:creator>
				<category><![CDATA[Binary numbers]]></category>
		<category><![CDATA[Binary integers]]></category>
		<category><![CDATA[Convert to hexadecimal]]></category>

		<guid isPermaLink="false">http://www.exploringbinary.com/?p=265</guid>
		<description><![CDATA[Binary/hexadecimal palindromes are integers that are palindromic in both binary and hexadecimal. Unlike binary/decimal palindromes, for example, they have a predictable structure. This means they can be generated directly, rather than searched for. So what is their structure? Certainly they&#8217;re made up of the hexadecimal digits that are themselves palindromic in binary: 0, 6, 9, [...]<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/the-structure-of-binary-hexadecimal-palindromes/">The Structure of Binary/Hexadecimal Palindromes</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Binary/hexadecimal palindromes are integers that are palindromic in both binary and hexadecimal. Unlike binary/decimal palindromes, for example, they have a predictable structure. This means they can be generated directly, rather than <a href="http://www.exploringbinary.com/finding-numbers-that-are-palindromic-in-multiple-bases/" title="Read Rick Regan's Article &ldquo;Finding Numbers That Are Palindromic In Multiple Bases&rdquo;">searched for</a>. So what is their structure?</p>
<p>Certainly they&#8217;re made up of the hexadecimal digits that are themselves palindromic in binary: 0, 6, 9, F; for example, F060F<sub>16</sub> = 11110000011000001111<sub>2</sub> and 9F9<sub>16</sub> = 100111111001<sub>2</sub>. Each of these four hexadecimal digits maps neatly to a 4-digit binary palindrome, so any hexadecimal palindrome made from them is automatically palindromic in binary.</p>
<p>But there are other binary/hexadecimal palindromes, like 525<sub>16</sub> = 10100100101<sub>2</sub> and 70207<sub>16</sub> = 1110000001000000111<sub>2</sub>, that contain hexadecimal digits that are <em>not</em> palindromic in binary. In this case, binary palindromes are produced with <em>combinations</em> of hexadecimal digits. It turns out there are a limited number of valid combinations, and that they&#8217;re localized &#8212; they span only <em>two</em> hexadecimal digits.</p>
<p>In this article, I&#8217;ll analyze binary/hexadecimal palindromes and describe their structure &#8212; a structure due to the relationship of the two bases, binary and hexadecimal.</p>
<div class="wp-caption aligncenter" style="width: 544px"><img src="http://www.exploringbinary.com/wp-content/uploads/hex-bin-palindromes.png" alt="Example Binary/Hexadecimal Palindromes" width="534" height="213"/><p class="wp-caption-text">Example Binary/Hexadecimal Palindromes</p></div>
<p><span id="more-265"></span></p>
<h2>Inferring the Structure of Binary/Hexadecimal Palindromes</h2>
<p>Before determining the structure of binary/hexadecimal palindromes analytically, let&#8217;s look at more examples. I listed the first 124 (nonzero) binary/hexadecimal palindromes &#8212; that is, those palindromes consisting of five hexadecimal  digits or less &#8212; using my <a href="http://www.exploringbinary.com/finding-numbers-that-are-palindromic-in-multiple-bases/" title="Read Rick Regan's Article &ldquo;Finding Numbers That Are Palindromic In Multiple Bases&rdquo;">C program that finds multi-base palindromes</a>. I noticed that each palindrome starts (and thus ends) with one of six hexadecimal digits: 1, 3, 5, 7, 9, F. I also noticed that, depending on the starting digit, only certain middle digits appear:</p>
<ul>
<li>Palindromes starting with 1: only 0 and 1 appear as middle digits.</li>
<li>Palindromes starting with 3: only 0 and 3 appear as middle digits.</li>
<li>Palindromes starting with 5 or 7: only 0, 2, 5, and 7 appear as middle digits.</li>
<li>Palindromes starting with 9 or F: only 0, 6, 9, and F appear as middle digits.</li>
</ul>
<p>Within each of the four groups of palindromes, the middle digits alternate in each digit position, in the order listed above. </p>
<p>Here is the output of my program, segmented by starting digit (the highlighted digits in the hexadecimal palindromes are the digits &ldquo;inserted&rdquo; into them to take them from n digits to n+1 digits):</p>
<p>Palindromes starting with hex &lsquo;1&rsquo;:</p>
<table class="center" border="1" summary="1-5 digit binary/hex palindromes, starting with hex 1)">
<caption><strong>Binary/Hexadecimal Palindromes (1-5 Hex Digits, Starting with 1<sub>16</sub>)</strong></caption>
<tbody>
<tr>
<th class="center">Hexadecimal</th>
<th class="center">Binary</th>
</tr>
<tr>
<td class="right internal_border_bottom">1<sub>16</sub></td>
<td class="right internal_border_bottom">1<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top_bottom"><span class="highlight_theme_blue">1</span>1<sub>16</sub></td>
<td class="right internal_border_top_bottom">10001<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">1<span class="highlight_theme_blue">0</span>1<sub>16</sub></td>
<td class="right internal_border_top">100000001<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_bottom">1<span class="highlight_theme_blue">1</span>1<sub>16</sub></td>
<td class="right internal_border_bottom">100010001<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">1<span class="highlight_theme_blue">0</span>01<sub>16</sub></td>
<td class="right internal_border_top">1000000000001<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_bottom">1<span class="highlight_theme_blue">1</span>11<sub>16</sub></td>
<td class="right internal_border_bottom">1000100010001<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">10<span class="highlight_theme_blue">0</span>01<sub>16</sub></td>
<td class="right internal_border_top">10000000000000001<sub>2</sub></td>
</tr>
<tr>
<td class="right">10<span class="highlight_theme_blue">1</span>01<sub>16</sub></td>
<td class="right">10000000100000001<sub>2</sub></td>
</tr>
<tr>
<td class="right">11<span class="highlight_theme_blue">0</span>11<sub>16</sub></td>
<td class="right">10001000000010001<sub>2</sub></td>
</tr>
<tr>
<td class="right">11<span class="highlight_theme_blue">1</span>11<sub>16</sub></td>
<td class="right">10001000100010001<sub>2</sub></td>
</tr>
</tbody>
</table>
<p class="break">Palindromes starting with &lsquo;3&rsquo;:</p>
<table class="center" border="1" summary="1-5 digit binary/hex palindromes, starting with hex 3)">
<caption><strong>Binary/Hexadecimal Palindromes (1-5 Hex Digits, Starting with 3<sub>16</sub>)</strong></caption>
<tbody>
<tr>
<th class="center">Hexadecimal</th>
<th class="center">Binary</th>
</tr>
<tr>
<td class="right internal_border_bottom">3<sub>16</sub></td>
<td class="right internal_border_bottom">11<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top_bottom"><span class="highlight_theme_blue">3</span>3<sub>16</sub></td>
<td class="right internal_border_top_bottom">110011<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">3<span class="highlight_theme_blue">0</span>3<sub>16</sub></td>
<td class="right internal_border_top">1100000011<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_bottom">3<span class="highlight_theme_blue">3</span>3<sub>16</sub></td>
<td class="right internal_border_bottom">1100110011<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">3<span class="highlight_theme_blue">0</span>03<sub>16</sub></td>
<td class="right internal_border_top">11000000000011<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_bottom">3<span class="highlight_theme_blue">3</span>33<sub>16</sub></td>
<td class="right internal_border_bottom">11001100110011<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">30<span class="highlight_theme_blue">0</span>03<sub>16</sub></td>
<td class="right internal_border_top">110000000000000011<sub>2</sub></td>
</tr>
<tr>
<td class="right">30<span class="highlight_theme_blue">3</span>03<sub>16</sub></td>
<td class="right">110000001100000011<sub>2</sub></td>
</tr>
<tr>
<td class="right">33<span class="highlight_theme_blue">0</span>33<sub>16</sub></td>
<td class="right">110011000000110011<sub>2</sub></td>
</tr>
<tr>
<td class="right">33<span class="highlight_theme_blue">3</span>33<sub>16</sub></td>
<td class="right">110011001100110011<sub>2</sub></td>
</tr>
</tbody>
</table>
<p class="break">Palindromes starting with hex &lsquo;5&rsquo;:</p>
<table class="center" border="1" summary="1-5 digit binary/hex palindromes, starting with hex 5)">
<caption><strong>Binary/Hexadecimal Palindromes (1-5 Hex Digits, Starting with 5<sub>16</sub>)</strong></caption>
<tbody>
<tr>
<th class="center">Hexadecimal</th>
<th class="center">Binary</th>
</tr>
<tr>
<td class="right internal_border_bottom">5<sub>16</sub></td>
<td class="right internal_border_bottom">101<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top_bottom"><span class="highlight_theme_blue">5</span>5<sub>16</sub></td>
<td class="right internal_border_top_bottom">1010101<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">5<span class="highlight_theme_blue">0</span>5<sub>16</sub></td>
<td class="right internal_border_top">10100000101<sub>2</sub></td>
</tr>
<tr>
<td class="right">5<span class="highlight_theme_blue">2</span>5<sub>16</sub></td>
<td class="right">10100100101<sub>2</sub></td>
</tr>
<tr>
<td class="right">5<span class="highlight_theme_blue">5</span>5<sub>16</sub></td>
<td class="right">10101010101<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_bottom">5<span class="highlight_theme_blue">7</span>5<sub>16</sub></td>
<td class="right internal_border_bottom">10101110101<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">5<span class="highlight_theme_blue">0</span>05<sub>16</sub></td>
<td class="right internal_border_top">101000000000101<sub>2</sub></td>
</tr>
<tr>
<td class="right">5<span class="highlight_theme_blue">2</span>25<sub>16</sub></td>
<td class="right">101001000100101<sub>2</sub></td>
</tr>
<tr>
<td class="right">5<span class="highlight_theme_blue">5</span>55<sub>16</sub></td>
<td class="right">101010101010101<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_bottom">5<span class="highlight_theme_blue">7</span>75<sub>16</sub></td>
<td class="right internal_border_bottom">101011101110101<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">50<span class="highlight_theme_blue">0</span>05<sub>16</sub></td>
<td class="right internal_border_top">1010000000000000101<sub>2</sub></td>
</tr>
<tr>
<td class="right">50<span class="highlight_theme_blue">2</span>05<sub>16</sub></td>
<td class="right">1010000001000000101<sub>2</sub></td>
</tr>
<tr>
<td class="right">50<span class="highlight_theme_blue">5</span>05<sub>16</sub></td>
<td class="right">1010000010100000101<sub>2</sub></td>
</tr>
<tr>
<td class="right">50<span class="highlight_theme_blue">7</span>05<sub>16</sub></td>
<td class="right">1010000011100000101<sub>2</sub></td>
</tr>
<tr>
<td class="right">52<span class="highlight_theme_blue">0</span>25<sub>16</sub></td>
<td class="right">1010010000000100101<sub>2</sub></td>
</tr>
<tr>
<td class="right">52<span class="highlight_theme_blue">2</span>25<sub>16</sub></td>
<td class="right">1010010001000100101<sub>2</sub></td>
</tr>
<tr>
<td class="right">52<span class="highlight_theme_blue">5</span>25<sub>16</sub></td>
<td class="right">1010010010100100101<sub>2</sub></td>
</tr>
<tr>
<td class="right">52<span class="highlight_theme_blue">7</span>25<sub>16</sub></td>
<td class="right">1010010011100100101<sub>2</sub></td>
</tr>
<tr>
<td class="right">55<span class="highlight_theme_blue">0</span>55<sub>16</sub></td>
<td class="right">1010101000001010101<sub>2</sub></td>
</tr>
<tr>
<td class="right">55<span class="highlight_theme_blue">2</span>55<sub>16</sub></td>
<td class="right">1010101001001010101<sub>2</sub></td>
</tr>
<tr>
<td class="right">55<span class="highlight_theme_blue">5</span>55<sub>16</sub></td>
<td class="right">1010101010101010101<sub>2</sub></td>
</tr>
<tr>
<td class="right">55<span class="highlight_theme_blue">7</span>55<sub>16</sub></td>
<td class="right">1010101011101010101<sub>2</sub></td>
</tr>
<tr>
<td class="right">57<span class="highlight_theme_blue">0</span>75<sub>16</sub></td>
<td class="right">1010111000001110101<sub>2</sub></td>
</tr>
<tr>
<td class="right">57<span class="highlight_theme_blue">2</span>75<sub>16</sub></td>
<td class="right">1010111001001110101<sub>2</sub></td>
</tr>
<tr>
<td class="right">57<span class="highlight_theme_blue">5</span>75<sub>16</sub></td>
<td class="right">1010111010101110101<sub>2</sub></td>
</tr>
<tr>
<td class="right">57<span class="highlight_theme_blue">7</span>75<sub>16</sub></td>
<td class="right">1010111011101110101<sub>2</sub></td>
</tr>
</tbody>
</table>
<p class="break">Palindromes starting with hex &lsquo;7&rsquo;:</p>
<table class="center" border="1" summary="1-5 digit binary/hex palindromes, starting with hex 7)">
<caption><strong>Binary/Hexadecimal Palindromes (1-5 Hex Digits, Starting with 7<sub>16</sub>)</strong></caption>
<tbody>
<tr>
<th class="center">Hexadecimal</th>
<th class="center">Binary</th>
</tr>
<tr>
<td class="right internal_border_bottom">7<sub>16</sub></td>
<td class="right internal_border_bottom">111<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top_bottom"><span class="highlight_theme_blue">7</span>7<sub>16</sub></td>
<td class="right internal_border_top_bottom">1110111<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">7<span class="highlight_theme_blue">0</span>7<sub>16</sub></td>
<td class="right internal_border_top">11100000111<sub>2</sub></td>
</tr>
<tr>
<td class="right">7<span class="highlight_theme_blue">2</span>7<sub>16</sub></td>
<td class="right">11100100111<sub>2</sub></td>
</tr>
<tr>
<td class="right">7<span class="highlight_theme_blue">5</span>7<sub>16</sub></td>
<td class="right">11101010111<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_bottom">7<span class="highlight_theme_blue">7</span>7<sub>16</sub></td>
<td class="right internal_border_bottom">11101110111<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">7<span class="highlight_theme_blue">0</span>07<sub>16</sub></td>
<td class="right internal_border_top">111000000000111<sub>2</sub></td>
</tr>
<tr>
<td class="right">7<span class="highlight_theme_blue">2</span>27<sub>16</sub></td>
<td class="right">111001000100111<sub>2</sub></td>
</tr>
<tr>
<td class="right">7<span class="highlight_theme_blue">5</span>57<sub>16</sub></td>
<td class="right">111010101010111<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_bottom">7<span class="highlight_theme_blue">7</span>77<sub>16</sub></td>
<td class="right internal_border_bottom">111011101110111<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">70<span class="highlight_theme_blue">0</span>07<sub>16</sub></td>
<td class="right internal_border_top">1110000000000000111<sub>2</sub></td>
</tr>
<tr>
<td class="right">70<span class="highlight_theme_blue">2</span>07<sub>16</sub></td>
<td class="right">1110000001000000111<sub>2</sub></td>
</tr>
<tr>
<td class="right">70<span class="highlight_theme_blue">5</span>07<sub>16</sub></td>
<td class="right">1110000010100000111<sub>2</sub></td>
</tr>
<tr>
<td class="right">70<span class="highlight_theme_blue">7</span>07<sub>16</sub></td>
<td class="right">1110000011100000111<sub>2</sub></td>
</tr>
<tr>
<td class="right">72<span class="highlight_theme_blue">0</span>27<sub>16</sub></td>
<td class="right">1110010000000100111<sub>2</sub></td>
</tr>
<tr>
<td class="right">72<span class="highlight_theme_blue">2</span>27<sub>16</sub></td>
<td class="right">1110010001000100111<sub>2</sub></td>
</tr>
<tr>
<td class="right">72<span class="highlight_theme_blue">5</span>27<sub>16</sub></td>
<td class="right">1110010010100100111<sub>2</sub></td>
</tr>
<tr>
<td class="right">72<span class="highlight_theme_blue">7</span>27<sub>16</sub></td>
<td class="right">1110010011100100111<sub>2</sub></td>
</tr>
<tr>
<td class="right">75<span class="highlight_theme_blue">0</span>57<sub>16</sub></td>
<td class="right">1110101000001010111<sub>2</sub></td>
</tr>
<tr>
<td class="right">75<span class="highlight_theme_blue">2</span>57<sub>16</sub></td>
<td class="right">1110101001001010111<sub>2</sub></td>
</tr>
<tr>
<td class="right">75<span class="highlight_theme_blue">5</span>57<sub>16</sub></td>
<td class="right">1110101010101010111<sub>2</sub></td>
</tr>
<tr>
<td class="right">75<span class="highlight_theme_blue">7</span>57<sub>16</sub></td>
<td class="right">1110101011101010111<sub>2</sub></td>
</tr>
<tr>
<td class="right">77<span class="highlight_theme_blue">0</span>77<sub>16</sub></td>
<td class="right">1110111000001110111<sub>2</sub></td>
</tr>
<tr>
<td class="right">77<span class="highlight_theme_blue">2</span>77<sub>16</sub></td>
<td class="right">1110111001001110111<sub>2</sub></td>
</tr>
<tr>
<td class="right">77<span class="highlight_theme_blue">5</span>77<sub>16</sub></td>
<td class="right">1110111010101110111<sub>2</sub></td>
</tr>
<tr>
<td class="right">77<span class="highlight_theme_blue">7</span>77<sub>16</sub></td>
<td class="right">1110111011101110111<sub>2</sub></td>
</tr>
</tbody>
</table>
<p class="break">Palindromes starting with hex &lsquo;9&rsquo;:</p>
<table class="center" border="1" summary="1-5 digit binary/hex palindromes, starting with hex 9)">
<caption><strong>Binary/Hexadecimal Palindromes (1-5 Hex Digits, Starting with 9<sub>16</sub>)</strong></caption>
<tbody>
<tr>
<th class="center">Hexadecimal</th>
<th class="center">Binary</th>
</tr>
<tr>
<td class="right internal_border_bottom">9<sub>16</sub></td>
<td class="right internal_border_bottom">1001<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top_bottom"><span class="highlight_theme_blue">9</span>9<sub>16</sub></td>
<td class="right internal_border_top_bottom">10011001<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">9<span class="highlight_theme_blue">0</span>9<sub>16</sub></td>
<td class="right internal_border_top">100100001001<sub>2</sub></td>
</tr>
<tr>
<td class="right">9<span class="highlight_theme_blue">6</span>9<sub>16</sub></td>
<td class="right">100101101001<sub>2</sub></td>
</tr>
<tr>
<td class="right">9<span class="highlight_theme_blue">9</span>9<sub>16</sub></td>
<td class="right">100110011001<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_bottom">9<span class="highlight_theme_blue">F</span>9<sub>16</sub></td>
<td class="right internal_border_bottom">100111111001<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">9<span class="highlight_theme_blue">0</span>09<sub>16</sub></td>
<td class="right internal_border_top">1001000000001001<sub>2</sub></td>
</tr>
<tr>
<td class="right">9<span class="highlight_theme_blue">6</span>69<sub>16</sub></td>
<td class="right">1001011001101001<sub>2</sub></td>
</tr>
<tr>
<td class="right">9<span class="highlight_theme_blue">9</span>99<sub>16</sub></td>
<td class="right">1001100110011001<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_bottom">9<span class="highlight_theme_blue">F</span>F9<sub>16</sub></td>
<td class="right internal_border_bottom">1001111111111001<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">90<span class="highlight_theme_blue">0</span>09<sub>16</sub></td>
<td class="right internal_border_top">10010000000000001001<sub>2</sub></td>
</tr>
<tr>
<td class="right">90<span class="highlight_theme_blue">6</span>09<sub>16</sub></td>
<td class="right">10010000011000001001<sub>2</sub></td>
</tr>
<tr>
<td class="right">90<span class="highlight_theme_blue">9</span>09<sub>16</sub></td>
<td class="right">10010000100100001001<sub>2</sub></td>
</tr>
<tr>
<td class="right">90<span class="highlight_theme_blue">F</span>09<sub>16</sub></td>
<td class="right">10010000111100001001<sub>2</sub></td>
</tr>
<tr>
<td class="right">96<span class="highlight_theme_blue">0</span>69<sub>16</sub></td>
<td class="right">10010110000001101001<sub>2</sub></td>
</tr>
<tr>
<td class="right">96<span class="highlight_theme_blue">6</span>69<sub>16</sub></td>
<td class="right">10010110011001101001<sub>2</sub></td>
</tr>
<tr>
<td class="right">96<span class="highlight_theme_blue">9</span>69<sub>16</sub></td>
<td class="right">10010110100101101001<sub>2</sub></td>
</tr>
<tr>
<td class="right">96<span class="highlight_theme_blue">F</span>69<sub>16</sub></td>
<td class="right">10010110111101101001<sub>2</sub></td>
</tr>
<tr>
<td class="right">99<span class="highlight_theme_blue">0</span>99<sub>16</sub></td>
<td class="right">10011001000010011001<sub>2</sub></td>
</tr>
<tr>
<td class="right">99<span class="highlight_theme_blue">6</span>99<sub>16</sub></td>
<td class="right">10011001011010011001<sub>2</sub></td>
</tr>
<tr>
<td class="right">99<span class="highlight_theme_blue">9</span>99<sub>16</sub></td>
<td class="right">10011001100110011001<sub>2</sub></td>
</tr>
<tr>
<td class="right">99<span class="highlight_theme_blue">F</span>99<sub>16</sub></td>
<td class="right">10011001111110011001<sub>2</sub></td>
</tr>
<tr>
<td class="right">9F<span class="highlight_theme_blue">0</span>F9<sub>16</sub></td>
<td class="right">10011111000011111001<sub>2</sub></td>
</tr>
<tr>
<td class="right">9F<span class="highlight_theme_blue">6</span>F9<sub>16</sub></td>
<td class="right">10011111011011111001<sub>2</sub></td>
</tr>
<tr>
<td class="right">9F<span class="highlight_theme_blue">9</span>F9<sub>16</sub></td>
<td class="right">10011111100111111001<sub>2</sub></td>
</tr>
<tr>
<td class="right">9F<span class="highlight_theme_blue">F</span>F9<sub>16</sub></td>
<td class="right">10011111111111111001<sub>2</sub></td>
</tr>
</tbody>
</table>
<p class="break">Palindromes starting with hex &lsquo;F&rsquo;:</p>
<table class="center" border="1" summary="1-5 digit binary/hex palindromes, starting with hex F)">
<caption><strong>Binary/Hexadecimal Palindromes (1-5 Hex Digits, Starting with F<sub>16</sub>)</strong></caption>
<tbody>
<tr>
<th class="center">Hexadecimal</th>
<th class="center">Binary</th>
</tr>
<tr>
<td class="right internal_border_bottom">F<sub>16</sub></td>
<td class="right internal_border_bottom">1111<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top_bottom"><span class="highlight_theme_blue">F</span>F<sub>16</sub></td>
<td class="right internal_border_top_bottom">11111111<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">F<span class="highlight_theme_blue">0</span>F<sub>16</sub></td>
<td class="right internal_border_top">111100001111<sub>2</sub></td>
</tr>
<tr>
<td class="right">F<span class="highlight_theme_blue">6</span>F<sub>16</sub></td>
<td class="right">111101101111<sub>2</sub></td>
</tr>
<tr>
<td class="right">F<span class="highlight_theme_blue">9</span>F<sub>16</sub></td>
<td class="right">111110011111<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_bottom">F<span class="highlight_theme_blue">F</span>F<sub>16</sub></td>
<td class="right internal_border_bottom">111111111111<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">F<span class="highlight_theme_blue">0</span>0F<sub>16</sub></td>
<td class="right internal_border_top">1111000000001111<sub>2</sub></td>
</tr>
<tr>
<td class="right">F<span class="highlight_theme_blue">6</span>6F<sub>16</sub></td>
<td class="right">1111011001101111<sub>2</sub></td>
</tr>
<tr>
<td class="right">F<span class="highlight_theme_blue">9</span>9F<sub>16</sub></td>
<td class="right">1111100110011111<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_bottom">F<span class="highlight_theme_blue">F</span>FF<sub>16</sub></td>
<td class="right internal_border_bottom">1111111111111111<sub>2</sub></td>
</tr>
<tr>
<td class="right internal_border_top">F0<span class="highlight_theme_blue">0</span>0F<sub>16</sub></td>
<td class="right internal_border_top">11110000000000001111<sub>2</sub></td>
</tr>
<tr>
<td class="right">F0<span class="highlight_theme_blue">6</span>0F<sub>16</sub></td>
<td class="right">11110000011000001111<sub>2</sub></td>
</tr>
<tr>
<td class="right">F0<span class="highlight_theme_blue">9</span>0F<sub>16</sub></td>
<td class="right">11110000100100001111<sub>2</sub></td>
</tr>
<tr>
<td class="right">F0<span class="highlight_theme_blue">F</span>0F<sub>16</sub></td>
<td class="right">11110000111100001111<sub>2</sub></td>
</tr>
<tr>
<td class="right">F6<span class="highlight_theme_blue">0</span>6F<sub>16</sub></td>
<td class="right">11110110000001101111<sub>2</sub></td>
</tr>
<tr>
<td class="right">F6<span class="highlight_theme_blue">6</span>6F<sub>16</sub></td>
<td class="right">11110110011001101111<sub>2</sub></td>
</tr>
<tr>
<td class="right">F6<span class="highlight_theme_blue">9</span>6F<sub>16</sub></td>
<td class="right">11110110100101101111<sub>2</sub></td>
</tr>
<tr>
<td class="right">F6<span class="highlight_theme_blue">F</span>6F<sub>16</sub></td>
<td class="right">11110110111101101111<sub>2</sub></td>
</tr>
<tr>
<td class="right">F9<span class="highlight_theme_blue">0</span>9F<sub>16</sub></td>
<td class="right">11111001000010011111<sub>2</sub></td>
</tr>
<tr>
<td class="right">F9<span class="highlight_theme_blue">6</span>9F<sub>16</sub></td>
<td class="right">11111001011010011111<sub>2</sub></td>
</tr>
<tr>
<td class="right">F9<span class="highlight_theme_blue">9</span>9F<sub>16</sub></td>
<td class="right">11111001100110011111<sub>2</sub></td>
</tr>
<tr>
<td class="right">F9<span class="highlight_theme_blue">F</span>9F<sub>16</sub></td>
<td class="right">11111001111110011111<sub>2</sub></td>
</tr>
<tr>
<td class="right">FF<span class="highlight_theme_blue">0</span>FF<sub>16</sub></td>
<td class="right">11111111000011111111<sub>2</sub></td>
</tr>
<tr>
<td class="right">FF<span class="highlight_theme_blue">6</span>FF<sub>16</sub></td>
<td class="right">11111111011011111111<sub>2</sub></td>
</tr>
<tr>
<td class="right">FF<span class="highlight_theme_blue">9</span>FF<sub>16</sub></td>
<td class="right">11111111100111111111<sub>2</sub></td>
</tr>
<tr>
<td class="right">FF<span class="highlight_theme_blue">F</span>FF<sub>16</sub></td>
<td class="right">11111111111111111111<sub>2</sub></td>
</tr>
</tbody>
</table>
<p class="break">You can see that binary palindromes starting with hex digits 1, 3, 5, and 7 are not multiples of four bits. This is because leading zeros do not count. Each of those four hex digits &#8212; when used as a starting digit &#8212; requires less than four bits. In this case, it&#8217;s important to remember that hex digits are formed in groups of four bits, <em>from right to left</em>.</p>
<h2>Starting Digits</h2>
<p>We&#8217;ve seen empirically that a <strong>nonzero binary/hexadecimal palindrome starts with the hexadecimal digit 1, 3, 5, 7, 9, or F</strong> &#8212; now it&#8217;s time to prove it.</p>
<p>First, observe that the starting hex digit must be odd: an even hex digit ends with a 0 when written in binary, and palindromes can&#8217;t start with 0. This leaves eight starting digits as candidates: 1, 3, 5, 7, 9, B, D, F.</p>
<p>Let&#8217;s classify our palindromes into two categories: single hex digit and multiple hex digit. A single hex digit palindrome is a single hex digit that is palindromic in binary: 1, 3, 5, 7, 9, and F are the only choices (1<sub>16</sub> = 1<sub>2</sub>, 3<sub>16</sub> = 11<sub>2</sub>, 5<sub>16</sub> = 101<sub>2</sub>, 7<sub>16</sub> = 111<sub>2</sub>, 9<sub>16</sub> = 1001<sub>2</sub>, F<sub>16</sub> = 1111<sub>2</sub>). A multiple hex digit palindrome <em>as a whole</em> is palindromic in binary, but individually, each hex digit may not be &#8212; and in fact, <em>will</em> not be &#8212; palindromic in binary.</p>
<p>Let&#8217;s analyze multiple hex digit palindromes by classifying them into two categories, depending on whether their ending hex digit has a binary equivalent that starts with a 1 or 0:</p>
<ul>
<li><strong>Binary equivalent starts with 1</strong>.
<p>The hexadecimal palindrome will have an associated binary palindrome that is a multiple of four bits. This means that each hex digit must stand alone as a binary palindrome: 9 and F are the only choices for the starting digit. There are two 2-digit palindromes that start with 9 and F: 99<sub>16</sub> = 10011001<sub>2</sub> and FF<sub>16</sub> = 11111111<sub>2</sub>; these will serve as &ldquo;bookends&rdquo; for all palindromes of 3 digits or more.</p>
</li>
<li><strong>Binary equivalent starts with 0</strong>.
<p>The hexadecimal palindrome will have an associated binary palindrome that is <em>not</em> a multiple of four bits. This means that each hex digit does <em>not</em> stand alone as a binary palindrome.</p>
<p>The best way to show which starting digits are allowed in this case is to try all four candidates as 2-digit palindromes: 11<sub>16</sub> = 10001<sub>2</sub>, 33<sub>16</sub> = 110011<sub>2</sub>, 55<sub>16</sub> = 1010101<sub>2</sub>, and 77<sub>16</sub> = 1110111<sub>2</sub>. All are binary palindromes, so 1, 3, 5, 7 are the valid starting digits.</p>
</li>
</ul>
<h2>Middle Digits</h2>
<p>We’ve seen empirically what the middle digits of multiple digit binary/hexadecimal palindromes are, and that they follow a pattern &#8212; now I&#8217;ll show why.</p>
<p><strong>Definition</strong>. I&#8217;ll say a number is a <em><strong>leading-zero palindrome</strong></em> or is <em><strong>leading-zero palindromic</strong></em> if it is palindromic with zero or more leading zeros. </p>
<h3>Middle Digits for Starting Digits 9, F</h3>
<p>Palindromes starting with 9 or F are straightforward to analyze, so I&#8217;ll start with them. Each middle hex digit must stand alone as a leading-zero binary palindrome, so 0, 6, 9, and F are the choices.</p>
<p>The structure of these palindromes is easy to describe. The n+1 hex digit palindromes can be created from the n hex digit palindromes by inserting the digits 0, 6, 9, or F. When n is odd, one n+1 digit palindrome is spawned from each n digit palindrome, by replicating the middle hex digit (which will be 0, 6, 9 or F). When n is even, four n+1 digit palindromes are spawned from each n digit palindrome, by inserting the digits 0, 6, 9, and F in turn.</p>
<h3>Middle Digits for Starting Digits 1, 3, 5, 7</h3>
<p>The analysis of palindromes starting with 1, 3, 5, or 7 is based on the number of leading zeros in the binary representation of the ending hex digit; let&#8217;s define the three cases:</p>
<ul>
<li>1 leading zero: 5 (0101) and 7 (0111).</li>
<li>2 leading zeros: 3 (0011).</li>
<li>3 leading zeros: 1 (0001).</li>
</ul>
<p>Recall how palindrome generation works: each inserted hex digit takes an n digit palindrome and turns it into an n+1 digit palindrome. To ensure the result remains a binary palindrome, the inserted hex digit must maintain a binary palindrome around the &ldquo;center&rdquo;. Here&#8217;s how it&#8217;s done:</p>
<ul>
<li>The binary representation of the inserted hex digit must have the same number of leading zeros as the binary representation of the hex digit to its right.</li>
<li>The binary representation of the inserted hex digit must be palindromic without the leading zeros.</li>
</ul>
<p>In other words, the inserted leading zeros mirror the existing leading zeros, and the rest of the hex digit &#8212; which is between the sets of zeros &#8212; stands alone as a binary palindrome.</p>
<p>(There&#8217;s an alternate way to think of this: the inserted hex digit, with the one, two, or three leading binary zeros in the hex digit to its right, is a leading zero palindrome. The left side of this palindrome replaces the leading zeros used from the right.)</p>
<p>So what are the allowable middle digits? Hex digits 0-7 are the candidates, since they&#8217;re the only 4-bit hex digits that have leading zeros in their binary representations. But after you strip away the required number of leading zeros, only 0, 1, 2, 3, 5, and 7 stand alone as binary palindromes:</p>
<ul>
<li>1 leading zero: 0 (000), 2 (010), 5 (101), 7 (111).</li>
<li>2 leading zeros: 0 (00) or 3 (11).</li>
<li>3 leading zeros: 0 (0) or 1 (1).</li>
</ul>
<p>The insertion of middle digits can continue indefinitely, since the number of binary leading zeros in each group is the same for each digit. Any middle digit in each group can be adjacent to any other. The number of leading zeros in the ending digit is the number of leading zeros maintained throughout.</p>
<h4>Example</h4>
<p>This diagram shows an example of binary/hexadecimal palindrome generation:</p>
<div class="wp-caption aligncenter" style="width: 338px"><img src="http://www.exploringbinary.com/wp-content/uploads/palin-gen-example.png" alt="Example Binary/Hexadecimal Palindrome Generation" width="328" height="465"/><p class="wp-caption-text">Example Binary/Hexadecimal Palindrome Generation</p></div>
<h2>Summary</h2>
<p>In summary, the (nonzero) binary/hexadecimal palindromes are</p>
<ul>
<li>The single digit hexadecimal palindromes 1, 3, 5, 7, 9, and F.</li>
<li>All hexadecimal palindromes that start and end with 1 and have only 0s and 1s between.</li>
<li>All hexadecimal palindromes that start and end with 3 and have only 0s and 3s between.</li>
<li>All hexadecimal palindromes that start and end with 5 or 7 and have only 0s, 2s, 5s, and 7s between.</li>
<li>All hexadecimal palindromes that start and end with 9 or F and have only 0s, 6s, 9s, and Fs between.</li>
</ul>
<p class="break">(And now that we know their structure we can count them — see my article &ldquo;<a href="http://www.exploringbinary.com/counting-binary-hexadecimal-palindromes/" title="Read Rick Regan's Article &ldquo;Counting Binary/Hexadecimal Palindromes&rdquo;">Counting Binary/Hexadecimal Palindromes</a>&rdquo;.)</p>
<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/the-structure-of-binary-hexadecimal-palindromes/">The Structure of Binary/Hexadecimal Palindromes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.exploringbinary.com/the-structure-of-binary-hexadecimal-palindromes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Counting Binary and Hexadecimal Palindromes</title>
		<link>http://www.exploringbinary.com/counting-binary-and-hexadecimal-palindromes/</link>
		<comments>http://www.exploringbinary.com/counting-binary-and-hexadecimal-palindromes/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 16:00:59 +0000</pubDate>
		<dc:creator>Rick Regan</dc:creator>
				<category><![CDATA[Binary numbers]]></category>
		<category><![CDATA[Algebra]]></category>
		<category><![CDATA[Exponents]]></category>
		<category><![CDATA[Geometric series]]></category>
		<category><![CDATA[Proof]]></category>

		<guid isPermaLink="false">http://www.exploringbinary.com/?p=264</guid>
		<description><![CDATA[How many nonzero, n-digit, decimal number palindromes are there? These two formulas give the answer: When n is even: 9&#183;10n/2-1 When n is odd: 9&#183;10(n+1)/2-1 How many nonzero, decimal number palindromes are there, consisting of n-digits or less? These two formulas give the answer: When n is even: 2(10n/2 &#8211; 1) When n is odd: [...]<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/counting-binary-and-hexadecimal-palindromes/">Counting Binary and Hexadecimal Palindromes</a></p>
]]></description>
			<content:encoded><![CDATA[<p>How many nonzero, n-digit, decimal <a href="http://www.exploringbinary.com/finding-numbers-that-are-palindromic-in-multiple-bases/" title="Read Rick Regan's Article &ldquo;Finding Numbers That Are Palindromic In Multiple Bases&rdquo;">number palindromes</a> are there? These two <a title="Sloane's &ldquo;Number of nonzero palindromes of length n&rdquo;" href="http://www.research.att.com/~njas/sequences/A050683">formulas</a> give the answer: </p>
<ul>
<li>When n is even: 9&middot;10<sup>n/2-1</sup></li>
<li>When n is odd: 9&middot;10<sup>(n+1)/2-1</sup></li>
</ul>
<p>How many nonzero, decimal number palindromes are there, consisting of n-digits <em>or less</em>? These two <a title="Wolfram MathWorld Article on Palindromic Numbers" href="http://mathworld.wolfram.com/PalindromicNumber.html">formulas</a> give the answer: </p>
<ul>
<li>When n is even: 2(10<sup>n/2</sup> &#8211; 1)</li>
<li>When n is odd: 11&middot;10<sup>(n-1)/2</sup> &#8211; 2</li>
</ul>
<p>So for example, there are 900 5-digit decimal palindromes, 9,000 8-digit decimal palindromes, 1,098 decimal palindromes of 5 digits or less, and 19,998 decimal palindromes of 8 digits or less.</p>
<p>In this article, I will derive similar formulas to count binary and hexadecimal number palindromes.</p>
<p><span id="more-264"></span></p>
<h2>Binary Palindromes</h2>
<p>Number palindromes have a simple structure: n-digit palindromes are related to n-1 digit palindromes. You can think of generating palindromes as an iterative process, where you start with single-digit palindromes and work your way through palindromes of an increasing number of digits. Here&#8217;s an example of the process, using binary numbers:</p>
<ol>
<li>From the only (nonzero) one-digit palindrome, 1, make the two-digit palindrome 11.</li>
<li>From 11, make the two three-digit palindromes 101 and 111.</li>
<li>From 101, make 1001; from 111, make 1111.</li>
<li>From 1001, make 10001 and 10101; from 1111, make 11011 and 11111.</li>
<li>From 10001, make 100001; from 10101, make 101101; from 11011, make 110011; from 11111 make 111111.</li>
<li>&#8230;</li>
</ol>
<p>From each odd-length palindrome, you can generate <em>one</em> even-length palindrome; you have to replicate the middle digit in order to keep it palindromic. From each even-length palindrome, you can generate <em>two</em> odd-length palindromes, by inserting a 0 or 1 in the middle.</p>
<p>This table illustrates the structure better &#8212; it shows all 1 through 8 digit binary palindromes:</p>
<table class="center" border="1" summary="All 1 through 8 digit binary palindromes">
<caption><strong>1 to 8-Digit Binary Palindromes (not counting 0)</strong></caption>
<tbody>
<tr>
<th class="center">Num Digits (n)</th>
<th class="center">Binary Palindromes</th>
<th class="center">Num n-digit Palindromes</th>
<th class="center">Total Palindromes</th>
</tr>
<tr>
<td class="right">1</td>
<td class="right">
1
</td>
<td class="center">1</td>
<td class="center">1</td>
</tr>
<tr>
<td class="right">2</td>
<td class="right">
<span class="highlight_theme_blue ">1</span>1
</td>
<td class="center">1</td>
<td class="center">2</td>
</tr>
<tr>
<td class="right">3</td>
<td class="right">
1<span class="highlight_theme_blue ">0</span>1<br />
1<span class="highlight_theme_blue ">1</span>1
</td>
<td class="center">2</td>
<td class="center">4</td>
</tr>
<tr>
<td class="right">4</td>
<td class="right">
1<span class="highlight_theme_blue ">0</span>01<br />
1<span class="highlight_theme_blue ">1</span>11
</td>
<td class="center">2</td>
<td class="center">6</td>
</tr>
<tr>
<td class="right">5</td>
<td class="right">
10<span class="highlight_theme_blue ">0</span>01<br />
10<span class="highlight_theme_blue ">1</span>01<br />
11<span class="highlight_theme_blue ">0</span>11<br />
11<span class="highlight_theme_blue ">1</span>11
</td>
<td class="center">4</td>
<td class="center">10</td>
</tr>
<tr>
<td class="right">6</td>
<td class="right">
10<span class="highlight_theme_blue ">0</span>001<br />
10<span class="highlight_theme_blue ">1</span>101<br />
11<span class="highlight_theme_blue ">0</span>011<br />
11<span class="highlight_theme_blue ">1</span>111
</td>
<td class="center">4</td>
<td class="center">14</td>
</tr>
<tr>
<td class="right">7</td>
<td class="right">
100<span class="highlight_theme_blue ">0</span>001<br />
100<span class="highlight_theme_blue ">1</span>001<br />
101<span class="highlight_theme_blue ">0</span>101<br />
101<span class="highlight_theme_blue ">1</span>101<br />
110<span class="highlight_theme_blue ">0</span>011<br />
110<span class="highlight_theme_blue ">1</span>011<br />
111<span class="highlight_theme_blue ">0</span>111<br />
111<span class="highlight_theme_blue ">1</span>111
</td>
<td class="center">8</td>
<td class="center">22</td>
</tr>
<tr>
<td class="right">8</td>
<td class="right">
100<span class="highlight_theme_blue ">0</span>0001<br />
100<span class="highlight_theme_blue ">1</span>1001<br />
101<span class="highlight_theme_blue ">0</span>0101<br />
101<span class="highlight_theme_blue ">1</span>1101<br />
110<span class="highlight_theme_blue ">0</span>0011<br />
110<span class="highlight_theme_blue ">1</span>1011<br />
111<span class="highlight_theme_blue ">0</span>0111<br />
111<span class="highlight_theme_blue ">1</span>1111
</td>
<td class="center">8</td>
<td class="center">30</td>
</tr>
</tbody>
</table>
<h3>Counting Binary Palindromes</h3>
<p>As typical with things binary, there is a pattern in the palindromes involving powers of two. In this case, it&#8217;s easy to see why: each set of odd-length palindromes is double the size of the preceding set of even-length palindromes, and each set of even-length palindromes is the same size as the preceding set of odd-length palindromes. These two formulas capture this relationship, giving the number of n-digit binary palindromes:</p>
<ul>
<li>When n is even: 2<sup>n/2-1</sup></li>
<li>When n is odd: 2<sup>(n+1)/2-1</sup></li>
</ul>
<p>For n = 1 to 8, you can verify these formulas match the counts in the table: 1, 1, 2, 2, 4, 4, 8, 8.</p>
<p>(The formula can be stated in one expression as <img class='align_bottom' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/counting-binary-and-hexadecimal-palindromes/f370eed2d453b72bdcf3df9cae6de931.png' alt='\mbox{\footnotesize{\displaystyle{2^{\lfloor (n-1)/2 \rfloor}}}}'/>, which is the base 2 version of <img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/counting-binary-and-hexadecimal-palindromes/1a863f9f0683a328814a9eb1667012e8.png' alt='\mbox{\footnotesize{\displaystyle{(b-1) \cdot b^{\lfloor (n-1)/2 \rfloor}}}}'/>, <a title="Sloane's &ldquo;Number of palindromes of length n&rdquo;" href="http://www.research.att.com/~njas/sequences/A050683">the formula stated here</a>. I rewrote it into two parts to remove the slightly cumbersome &#8220;floor&#8221; function, and to be consistent with the formulas below.)</p>
<h4>Number of Binary Palindromes of n Digits or Less</h4>
<p>You can further derive a formula for the total number of palindromes of n digits or less, by adding the terms 1, 1, 2, 2, 4, 4, 8, 8, &#8230; . Recognizing this sequence as two interleaved sequences of 1, 2, 4, 8, &#8230; &#8212; that is, sequences of nonnegative powers of two &#8212; the derivation of the formula is straightforward. </p>
<p>Here&#8217;s the formula to express the sum of the first m nonnegative powers of two:</p>
<p class="center"><img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/counting-binary-and-hexadecimal-palindromes/a7caf098e64f4c7cefae4ba5d99311a9.png' alt='\mbox{\footnotesize{\displaystyle{\sum_{i=0}^{m-1}2^i}}}'/> = 2<sup>m</sup> &#8211; 1</p>
<p>We can use this expression for each of the interleaved series, and then add them together. There are two cases:</p>
<ul>
<li><strong>The number of digits n is even</strong>
<p>The sum consists of two identical series of n/2 terms each:</p>
<p><img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/counting-binary-and-hexadecimal-palindromes/759a5a69c86e49a3f5a72accf5d77b49.png' alt='\mbox{\footnotesize{\displaystyle{\sum_{i=0}^{\frac{n}{2}-1}2^i}}}'/> = 2<sup>n/2</sup> &#8211; 1.</p>
<p>Added together, they are <strong>2(2<sup>n/2</sup> &#8211; 1)</strong>.</p>
</li>
<li><strong>The number of digits n is odd</strong>
<p>The sum consists of two identical series of (n-1)/2 terms each, plus an extra term. Each series looks like this:</p>
<p><img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/counting-binary-and-hexadecimal-palindromes/e1b7237ca73f62e78f9e3fb5b0c376f0.png' alt='\mbox{\footnotesize{\displaystyle{\sum_{i=0}^{\frac{n-1}{2}-1}2^i}}}'/> = 2<sup>(n-1)/2</sup> &#8211; 1.</p>
<p>Added together, they are 2(2<sup>(n-1)/2</sup> &#8211; 1).</p>
<p>The extra term is 2<sup>(n-1)/2</sup>, what would have been the next term in one of the series. Adding this to the two series we get 2(2<sup>(n-1)/2</sup> &#8211; 1) + 2<sup>(n-1)/2</sup>, which simplifies to <strong>3&middot;2<sup>(n-1)/2</sup> &#8211; 2</strong>.</p>
</li>
</ul>
<p>For n = 1 to 8, you can verify these formulas match the total counts in the table: 1, 2, 4, 6, 10, 14, 22, 30.</p>
<h2>Hexadecimal Palindromes</h2>
<p>Using a similar analysis, here are the two formulas to count n-digit hexadecimal palindromes:</p>
<ul>
<li>When n is even: 15&middot;16<sup>n/2-1</sup></li>
<li>When n is odd: 15&middot;16<sup>(n+1)/2-1</sup></li>
</ul>
<p>For n = 1 to 8, the value of these formulas is 15, 15, 240, 240, 3840, 3840, 61440, 61440.</p>
<p>(The formula can also be stated in one expression as <img class='align_bottom' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/counting-binary-and-hexadecimal-palindromes/193348f2359821dbd724ab2115fa7f61.png' alt='\mbox{\footnotesize{\displaystyle{15 \cdot 16^{\lfloor (n-1)/2 \rfloor}}}}'/> .)</p>
<p>To count the number of hexadecimal palindromes of n digits or less, we can add series just as we did for binary palindromes. If you factor out 15 from each term in the sequence above, you&#8217;re left with this sequence: 1, 1, 16, 16, 256, 256, 4096, 4096. Those are interleaved sequences of nonnegative powers of sixteen.</p>
<p>Here’s the formula to express the sum of the first m nonnegative powers of sixteen:</p>
<p class="center"><img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/counting-binary-and-hexadecimal-palindromes/772c116c9d6e1a9e1691e83f9a6b298a.png' alt='\mbox{\footnotesize{\displaystyle{\sum_{i=0}^{m-1}16^i}}}'/> = (16<sup>m</sup> &#8211; 1)/15</p>
<p>We can use this expression for each of the interleaved sequences, and then add them together. There are two cases:</p>
<ul>
<li><strong>The number of digits n is even</strong>
<p>The sum consists of two identical series of n/2 terms each:</p>
<p><img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/counting-binary-and-hexadecimal-palindromes/d518e16c3809c2eb4d4b146e1458ef8b.png' alt='\mbox{\footnotesize{\displaystyle{15\sum_{i=0}^{\frac{n}{2}-1}16^i}}}'/> = 16<sup>n/2</sup> &#8211; 1.</p>
<p>Added together, they are <strong>2(16<sup>n/2</sup> &#8211; 1)</strong>.</p>
</li>
<li><strong>The number of digits n is odd</strong>
<p>The sum consists of two identical series of (n-1)/2 terms each, plus an extra term. Each series looks like this:</p>
<p><img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/counting-binary-and-hexadecimal-palindromes/e27fce5dc1e312e63e7db8afe486e621.png' alt='\mbox{\footnotesize{\displaystyle{15\sum_{i=0}^{\frac{n-1}{2}-1}16^i}}}'/> = 16<sup>(n-1)/2</sup> &#8211; 1.</p>
<p>Added together, they are 2(16<sup>(n-1)/2</sup> &#8211; 1).</p>
<p>The extra term is 15&middot;16<sup>(n-1)/2</sup>, what would have been the next term in one of the series. Adding this to the two series we get 2(16<sup>(n-1)/2</sup> &#8211; 1) + 15&middot;16<sup>(n-1)/2</sup>, which simplifies to <strong>17&middot;16<sup>(n-1)/2</sup> &#8211; 2</strong>.</p>
</li>
</ul>
<p>For n = 1 to 8, these formulas return these values: 15, 30, 270, 510, 4350, 8190, 69630, 131070.</p>
<h2>Trying These Formulas in PARI/GP</h2>
<p>In this section, I&#8217;ll demonstrate the formulas for counting binary palindromes, using <a href="http://www.exploringbinary.com/exploring-binary-numbers-with-parigp-calculator/" title="Read Rick Regan's Article &ldquo;Exploring Binary Numbers With PARI/GP Calculator&rdquo;">PARI/GP</a>.</p>
<p>Print the number of 1-digit to 20-digit binary palindromes, using the &#8220;floor&#8221; form of the expression:</p>
<pre>
? <strong>for (i=1,20,print(2^(floor((i-1)/2))))</strong>
1
1
2
2
4
4
8
8
16
16
32
32
64
64
128
128
256
256
512
512
</pre>
<p class="break">Print the number of 1-digit to 20-digit binary palindromes, using the even and odd case palindrome counting expressions:</p>
<pre>
? <strong>for(i=1,20,if(i%2==1,print(2^((i+1)/2-1)),print(2^(i/2-1))))</strong>
1
1
2
2
4
4
8
8
16
16
32
32
64
64
128
128
256
256
512
512
</pre>
<p class="break">Print the total number of binary palindromes of n digits or less, for n = 1 to 20:</p>
<pre>
? <strong>for(i=1,20,if(i%2==1,print(3*2^((i-1)/2)-2),print(2*(2^(i/2)-1))))</strong>
1
2
4
6
10
14
22
30
46
62
94
126
190
254
382
510
766
1022
1534
2046
</pre>
<h2>Summary</h2>
<p>Here is a summary of the binary palindrome counting formulas:</p>
<table class="center" border="1" summary="Summary of binary palindrome counting formulas">
<caption><strong>Nonzero Binary Palindrome Counting Formulas</strong></caption>
<tbody>
<tr>
<th class="center">Num Digits</th>
<th class="center">Even n</th>
<th class="center">Odd n</th>
</tr>
<tr>
<td class="left">n</td>
<td class="center">2<sup>n/2-1</sup></td>
<td class="center">2<sup>(n+1)/2-1</sup></td>
</tr>
<tr>
<td class="left">n or less</td>
<td class="center">2(2<sup>n/2</sup> &#8211; 1)</td>
<td class="center">3&middot;2<sup>(n-1)/2</sup> &#8211; 2</td>
</tr>
</tbody>
</table>
<p class="break">Here is a summary of the hexadecimal palindrome counting formulas:</p>
<table class="center" border="1" summary="Summary of hexadecimal palindrome counting formulas">
<caption><strong>Nonzero Hexadecimal Palindrome Counting Formulas</strong></caption>
<tbody>
<tr>
<th class="center">Num Digits</th>
<th class="center">Even n</th>
<th class="center">Odd n</th>
</tr>
<tr>
<td class="left">n</td>
<td class="center">15&middot;16<sup>n/2-1</sup></td>
<td class="center">15&middot;16<sup>(n+1)/2-1</sup></td>
</tr>
<tr>
<td class="left">n or less</td>
<td class="center">2(16<sup>n/2</sup> &#8211; 1)</td>
<td class="center">17&middot;16<sup>(n-1)/2</sup> &#8211; 2</td>
</tr>
</tbody>
</table>
<h2>Discussion</h2>
<p>These formulas can be extended to any base, like octal. (You can see the pattern they follow, although that in itself is not a proof they hold for all bases.)</p>
<p>In my article <a href="http://www.exploringbinary.com/finding-numbers-that-are-palindromic-in-multiple-bases/" title="Read Rick Regan's Article &ldquo;Finding Numbers That Are Palindromic In Multiple Bases&rdquo;">&ldquo;Finding Numbers That Are Palindromic In Multiple Bases&rdquo;</a> I showed how to generate palindromes by iterating through a counter. The analysis of palindromes in this article suggests another algorithm: generating n-digit palindromes from n-1 digit palindromes. (It&#8217;s probably not a better way though, at least not for large n, because the required storage space grows exponentially.)</p>
<h3>What About Zero?</h3>
<p><a title="Wikipedia article defining palindromic number" href="http://en.wikipedia.org/wiki/Palindromic_number">The number 0 is defined to be a palindrome</a>, although you could make an argument against it. No palindrome can start with zero, yet 0 is a palindrome. In any case, it is not counted in the formulas above, simply because it makes the derivations easier. To count zero, add one to each formula.</p>
<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/counting-binary-and-hexadecimal-palindromes/">Counting Binary and Hexadecimal Palindromes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.exploringbinary.com/counting-binary-and-hexadecimal-palindromes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Binary Dates in 2010 and 2011</title>
		<link>http://www.exploringbinary.com/binary-dates-in-2010-and-2011/</link>
		<comments>http://www.exploringbinary.com/binary-dates-in-2010-and-2011/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 20:51:54 +0000</pubDate>
		<dc:creator>Rick Regan</dc:creator>
				<category><![CDATA[Binary numbers]]></category>

		<guid isPermaLink="false">http://www.exploringbinary.com/?p=262</guid>
		<description><![CDATA[People have been tweeting about the upcoming dates that look like binary numbers. 10/10/10 seems to be a favorite, both because of its symmetry and because 101010 = 42 in decimal (you know, the answer to the ultimate question of life, the universe, and everything). Here are the nine dates in 2010, interpreted as binary [...]<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/binary-dates-in-2010-and-2011/">Binary Dates in 2010 and 2011</a></p>
]]></description>
			<content:encoded><![CDATA[<p>People have been tweeting about the upcoming dates that look like binary numbers. 10/10/10 seems to be a favorite, both because of its symmetry and because 101010 = 42 in decimal (you know, the <a title="Wikipedia article on &ldquo;The Hitchhiker&rsquo;s Guide to the Galaxy&rdquo;" href="http://en.wikipedia.org/wiki/Phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy#Answer_to_the_Ultimate_Question_of_Life.2C_the_Universe.2C_and_Everything_.2842.29">answer to the ultimate question of life, the universe, and everything</a>). Here are the nine dates in 2010, interpreted as binary numbers, and with their decimal equivalents:</p>
<p><span id="more-262"></span></p>
<table class="center" border="1" summary="Binary Dates in the Year 2010 (month/day/year)">
<caption><strong>Binary Dates in 2010 (mm/dd/yy)</strong></caption>
<tbody>
<tr>
<th class="center">Date</th>
<th class="center">mm/dd/yy</th>
<th class="center">Binary</th>
<th class="center">Decimal</th>
</tr>
<tr>
<td rowspan="2" class="left">January 1st, 2010</td>
<td class="right">1/1/10</td>
<td class="right">1110</td>
<td class="center">14</td>
</tr>
<tr>
<td class="right">1/01/10</td>
<td class="right">10110</td>
<td class="center">22</td>
</tr>
<tr>
<td class="left">January 10th, 2010</td>
<td class="right">1/10/10</td>
<td class="right">11010</td>
<td class="center">26</td>
</tr>
<tr>
<td class="left">January 11th, 2010</td>
<td class="right">1/11/10</td>
<td class="right">11110</td>
<td class="center">30</td>
</tr>
<tr>
<td rowspan="2" class="left">October 1st, 2010</td>
<td class="right">10/1/10</td>
<td class="right">10110</td>
<td class="center">22</td>
</tr>
<tr>
<td class="right">10/01/10</td>
<td class="right">100110</td>
<td class="center">38</td>
</tr>
<tr>
<td class="left">October 10th, 2010</td>
<td class="right">10/10/10</td>
<td class="right">101010</td>
<td class="center">42</td>
</tr>
<tr>
<td class="left">October 11th, 2010</td>
<td class="right">10/11/10</td>
<td class="right">101110</td>
<td class="center">46</td>
</tr>
<tr>
<td rowspan="2" class="left">November 1st, 2010</td>
<td class="right">11/1/10</td>
<td class="right">11110</td>
<td class="center">30</td>
</tr>
<tr>
<td class="right">11/01/10</td>
<td class="right">110110</td>
<td class="center">54</td>
</tr>
<tr>
<td class="left">November 10th, 2010</td>
<td class="right">11/10/10</td>
<td class="right">111010</td>
<td class="center">58</td>
</tr>
<tr>
<td class="left">November 11th, 2010</td>
<td class="right">11/11/10</td>
<td class="right">111110</td>
<td class="center">62</td>
</tr>
</tbody>
</table>
<p class="break">Here they are in dd/mm/yy format:</p>
<table class="center" border="1" summary="Binary Dates in the Year 2010 (day/month/year)">
<caption><strong>Binary Dates in 2010 (dd/mm/yy)</strong></caption>
<tbody>
<tr>
<th class="center">Date</th>
<th class="center">dd/mm/yy</th>
<th class="center">Binary</th>
<th class="center">Decimal</th>
</tr>
<tr>
<td rowspan="2" class="left">January 1st, 2010</td>
<td class="right">1/1/10</td>
<td class="right">1110</td>
<td class="center">14</td>
</tr>
<tr>
<td class="right">1/01/10</td>
<td class="right">10110</td>
<td class="center">22</td>
</tr>
<tr>
<td rowspan="2" class="left">January 10th, 2010</td>
<td class="right">10/1/10</td>
<td class="right">10110</td>
<td class="center">22</td>
</tr>
<tr>
<td class="right">10/01/10</td>
<td class="right">100110</td>
<td class="center">38</td>
</tr>
<tr>
<td rowspan="2" class="left">January 11th, 2010</td>
<td class="right">11/1/10</td>
<td class="right">11110</td>
<td class="center">30</td>
</tr>
<tr>
<td class="right">11/01/10</td>
<td class="right">110110</td>
<td class="center">54</td>
</tr>
<tr>
<td class="left">October 1st, 2010</td>
<td class="right">1/10/10</td>
<td class="right">11010</td>
<td class="center">26</td>
</tr>
<tr>
<td class="left">October 10th, 2010</td>
<td class="right">10/10/10</td>
<td class="right">101010</td>
<td class="center">42</td>
</tr>
<tr>
<td class="left">October 11th, 2010</td>
<td class="right">11/10/10</td>
<td class="right">111010</td>
<td class="center">58</td>
</tr>
<tr>
<td class="left">November 1st, 2010</td>
<td class="right">1/11/10</td>
<td class="right">11110</td>
<td class="center">30</td>
</tr>
<tr>
<td class="left">November 10th, 2010</td>
<td class="right">10/11/10</td>
<td class="right">101110</td>
<td class="center">46</td>
</tr>
<tr>
<td class="left">November 11th, 2010</td>
<td class="right">11/11/10</td>
<td class="right">111110</td>
<td class="center">62</td>
</tr>
</tbody>
</table>
<h2>2011</h2>
<p>The same days also look like binary in 2011:</p>
<table class="center" border="1" summary="Binary Dates in the Year 2011 (month/day/year)">
<caption><strong>Binary Dates in 2011 (mm/dd/yy)</strong></caption>
<tbody>
<tr>
<th class="center">Date</th>
<th class="center">mm/dd/yy</th>
<th class="center">Binary</th>
<th class="center">Decimal</th>
</tr>
<tr>
<td rowspan="2" class="left">January 1st, 2011</td>
<td class="right">1/1/11</td>
<td class="right">1111</td>
<td class="center">15</td>
</tr>
<tr>
<td class="right">1/01/11</td>
<td class="right">10111</td>
<td class="center">23</td>
</tr>
<tr>
<td class="left">January 10th, 2011</td>
<td class="right">1/10/11</td>
<td class="right">11011</td>
<td class="center">27</td>
</tr>
<tr>
<td class="left">January 11th, 2011</td>
<td class="right">1/11/11</td>
<td class="right">11111</td>
<td class="center">31</td>
</tr>
<tr>
<td rowspan="2" class="left">October 1st, 2011</td>
<td class="right">10/1/11</td>
<td class="right">10111</td>
<td class="center">23</td>
</tr>
<tr>
<td class="right">10/01/11</td>
<td class="right">100111</td>
<td class="center">39</td>
</tr>
<tr>
<td class="left">October 10th, 2011</td>
<td class="right">10/10/11</td>
<td class="right">101011</td>
<td class="center">43</td>
</tr>
<tr>
<td class="left">October 11th, 2011</td>
<td class="right">10/11/11</td>
<td class="right">101111</td>
<td class="center">47</td>
</tr>
<tr>
<td rowspan="2" class="left">November 1st, 2011</td>
<td class="right">11/1/11</td>
<td class="right">11111</td>
<td class="center">31</td>
</tr>
<tr>
<td class="right">11/01/11</td>
<td class="right">110111</td>
<td class="center">55</td>
</tr>
<tr>
<td class="left">November 10th, 2011</td>
<td class="right">11/10/11</td>
<td class="right">111011</td>
<td class="center">59</td>
</tr>
<tr>
<td class="left">November 11th, 2011</td>
<td class="right">11/11/11</td>
<td class="right">111111</td>
<td class="center">63</td>
</tr>
</tbody>
</table>
<p class="break">Here they are in dd/mm/yy format:</p>
<table class="center" border="1" summary="Binary Dates in the Year 2011 (day/month/year)">
<caption><strong>Binary Dates in 2011 (dd/mm/yy)</strong></caption>
<tbody>
<tr>
<th class="center">Date</th>
<th class="center">dd/mm/yy</th>
<th class="center">Binary</th>
<th class="center">Decimal</th>
</tr>
<tr>
<td rowspan="2" class="left">January 1st, 2011</td>
<td class="right">1/1/11</td>
<td class="right">1111</td>
<td class="center">15</td>
</tr>
<tr>
<td class="right">1/01/11</td>
<td class="right">10111</td>
<td class="center">23</td>
</tr>
<tr>
<td rowspan="2" class="left">January 10th, 2011</td>
<td class="right">10/1/11</td>
<td class="right">10111</td>
<td class="center">23</td>
</tr>
<tr>
<td class="right">10/01/11</td>
<td class="right">100111</td>
<td class="center">39</td>
</tr>
<tr>
<td rowspan="2" class="left">January 11th, 2011</td>
<td class="right">11/1/11</td>
<td class="right">11111</td>
<td class="center">31</td>
</tr>
<tr>
<td class="right">11/01/11</td>
<td class="right">110111</td>
<td class="center">55</td>
</tr>
<tr>
<td class="left">October 1st, 2011</td>
<td class="right">1/10/11</td>
<td class="right">11011</td>
<td class="center">27</td>
</tr>
<tr>
<td class="left">October 10th, 2011</td>
<td class="right">10/10/11</td>
<td class="right">101011</td>
<td class="center">43</td>
</tr>
<tr>
<td class="left">October 11th, 2011</td>
<td class="right">11/10/11</td>
<td class="right">111011</td>
<td class="center">59</td>
</tr>
<tr>
<td class="left">November 1st, 2011</td>
<td class="right">1/11/11</td>
<td class="right">11111</td>
<td class="center">31</td>
</tr>
<tr>
<td class="left">November 10th, 2011</td>
<td class="right">10/11/11</td>
<td class="right">101111</td>
<td class="center">47</td>
</tr>
<tr>
<td class="left">November 11th, 2011</td>
<td class="right">11/11/11</td>
<td class="right">111111</td>
<td class="center">63</td>
</tr>
</tbody>
</table>
<p class="break">And in case you were wondering, 2010 = 11111011010 in binary, and 2011 = 11111011011 in binary.</p>
<p class="break">(If this blog existed in 2000 &#8212; if blogs existed in 2000 period &#8212; I would have made tables for the years 2000 and 2001 as well.)</p>
<h2>Palindromes</h2>
<p>Considering dates as numbers leads you to wonder which are <a href="http://www.exploringbinary.com/finding-numbers-that-are-palindromic-in-multiple-bases/" title="Read Rick Regan's Article &ldquo;Finding Numbers That Are Palindromic In Multiple Bases&rdquo;">number palindromes</a>. Numbers written with leading zeros are not palindromes, so numbers <em>ending</em> with zeros are not palindromes either. This means no dates in 2010 are palindromic. In 2011 however, there <em>are</em> palindromic dates. There are several consisting of all 1s, like 1/1/11, but those are not interesting. That leaves two palindromic dates made up of both 0s and 1s:</p>
<ul>
<li>January 10th, 2011, in mm/dd/yy format: 1/10/11.</li>
<li>October 1st, 2011, in dd/mm/yy format: 1/10/11.</li>
</ul>
<p>Both are the same binary number: 11011 (27 decimal).</p>
<h2>Binary Times</h2>
<p>People have also been <a href="http://twitter.com/vonec/status/7221144706" title="Tweet by user &ldquo;vonec&rdquo;">tweeting about binary <em>times</em></a>. There are binary times every day, but they&#8217;ll seem more significant on binary days. There are 12, not including seconds and duplicates for AM/PM: 1:00, 1:01, 1:10, 1:11, 10:00, 10:01, 10:10, 10:11, 11:00, 11:01, 11:10, 11:11. (I&#8217;ll leave it as an exercise to compute these as decimal values.)</p>
<p>Now having thrown time into the mix, we can consider some new palindromes. For example, 1/1/10 (mm/dd/yy) at 1:11 AM is 1110111.</p>
<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/binary-dates-in-2010-and-2011/">Binary Dates in 2010 and 2011</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.exploringbinary.com/binary-dates-in-2010-and-2011/feed/</wfw:commentRss>
		<slash:comments>43</slash:comments>
		</item>
		<item>
		<title>Nines in Quinary</title>
		<link>http://www.exploringbinary.com/nines-in-quinary/</link>
		<comments>http://www.exploringbinary.com/nines-in-quinary/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 16:08:25 +0000</pubDate>
		<dc:creator>Rick Regan</dc:creator>
				<category><![CDATA[Binary numbers]]></category>
		<category><![CDATA[Algebra]]></category>
		<category><![CDATA[Exponents]]></category>
		<category><![CDATA[Modular arithmetic]]></category>
		<category><![CDATA[Proof]]></category>

		<guid isPermaLink="false">http://www.exploringbinary.com/?p=247</guid>
		<description><![CDATA[In my article &#8220;Nines in Binary&#8221;, I proved the following: positive integers of the form 10n-1, that is, integers made up of n digits of 9s, have binary representations with exactly n digits of trailing 1s. Pat Ballew made a clever observation, adapting my result to prove an equivalent statement for base 5 (quinary): positive [...]<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/nines-in-quinary/">Nines in Quinary</a></p>
]]></description>
			<content:encoded><![CDATA[<p>In my article &ldquo;<a title="Read Rick Regan's Article &ldquo;Nines in Binary&rdquo;" href="http://www.exploringbinary.com/nines-in-binary/">Nines in Binary</a>&rdquo;, I proved the following: positive integers of the form 10<sup>n</sup>-1, that is, integers made up of n digits of 9s, have binary representations with exactly n digits of trailing 1s. <a title="Read Pat Ballew's Blog Post About Nines in Base 5" href="http://pballew.blogspot.com/2009/09/i-was-reading-interesting-blog-posted.html">Pat Ballew</a> made a clever observation, adapting my result to prove an equivalent statement for <a title="Wikipedia article defining base 5 (quinary)" href="http://en.wikipedia.org/wiki/Quinary">base 5 (quinary)</a>: positive integers of the form 10<sup>n</sup>-1 have quinary representations that have <strong>exactly n digits of trailing 4s</strong>. For example, 9999 in decimal is 304444 in quinary.</p>
<p>In &ldquo;<a title="Read Rick Regan's Article &ldquo;Nines in Binary&rdquo;" href="http://www.exploringbinary.com/nines-in-binary/">Nines in Binary</a>&rdquo;, I derived an expression for 10<sup>n</sup> &#8211; 1 that shows its structure as a binary number:</p>
<p class="center">10<sup>n</sup> &#8211; 1 = (5<sup>n</sup> &#8211; 1) 2<sup>n</sup> + (2<sup>n</sup> &#8211; 1)</p>
<p>Pat derived a similar expression for 10<sup>n</sup> &#8211; 1 that shows its structure as a <strong>quinary</strong> number:</p>
<p class="center">10<sup>n</sup> &#8211; 1 = (2<sup>n</sup> &#8211; 1) 5<sup>n</sup> + (5<sup>n</sup> &#8211; 1)</p>
<p>In essence, he swapped the 2s and 5s, making it the &#8220;dual&#8221; of my formula, if you will.</p>
<p>I&#8217;ll show the details of the derivation and prove why the formula works.</p>
<p><span id="more-247"></span></p>
<h2>Deriving the Expression</h2>
<p>To derive the formula for the &#8220;binary expression&#8221; of 10<sup>n</sup> &#8211; 1, I worked backwards from the patterns I saw in its binary representation:</p>
<p class="center">(5<sup>n</sup> &#8211; 1) 2<sup>n</sup> + (2<sup>n</sup> &#8211; 1) = 5<sup>n</sup>2<sup>n</sup> &#8211; 2<sup>n</sup> + 2<sup>n</sup> &#8211; 1 = 10<sup>n</sup> &#8211; 1</p>
<p>Pat derived the formula for the &#8220;quinary expression&#8221; of 10<sup>n</sup> &#8211; 1 without having to look at its representation in quinary &#8212; he simply modified the algebra that I presented. He observed that <strong>- 2<sup>n</sup> + 2<sup>n</sup></strong> could be replaced with <strong>- 5<sup>n</sup> + 5<sup>n</sup></strong>, since both equal 0. This allowed him to rearrange the expression as follows:</p>
<p class="center">10<sup>n</sup> &#8211; 1 = 2<sup>n</sup>5<sup>n</sup> &#8211; 5<sup>n</sup> + 5<sup>n</sup> &#8211; 1 = <strong>(2<sup>n</sup> &#8211; 1) 5<sup>n</sup> + (5<sup>n</sup> &#8211; 1)</strong></p>
<h2>What the Expression Shows</h2>
<p>The quinary expression has a leading part, 2<sup>n</sup> &#8211; 1 shifted left n places in base 5, and a trailing part, 5<sup>n</sup> &#8211; 1. The trailing part shows that there are at least n trailing 4s, since 5<sup>n</sup> &#8211; 1 is n 4s in quinary (like 2<sup>n</sup> &#8211; 1 is n 1s in binary, 10<sup>n</sup> &#8211; 1 is n 9s in decimal, etc.). The leading part shows that there are <em>exactly</em> n trailing 4s, since 2<sup>n</sup> &#8211; 1 does not end with the digit 4 in quinary. Let&#8217;s see why.</p>
<p>To show that 2<sup>n</sup> &#8211; 1, when expressed in base 5, does not end in 4, we can use <a title="Wikipedia article on modular arithmetic" href="http://en.wikipedia.org/wiki/Modular_arithmetic">modular arithmetic</a>. Let&#8217;s start by analyzing the possible ending digits of the <a title="Read Rick Regan's Article “A Table of Nonnegative Powers of Two” (positive powers of two start at 2)" href="http://www.exploringbinary.com/a-table-of-nonnegative-powers-of-two/">positive powers of two</a>:</p>
<ul>
<li><img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/nines-in-quinary/2c53ee0d065e7f59ccb35f4c12284f60.png' alt='\mbox{\footnotesize{\displaystyle{2^1 \equiv 2 \pmod{5}}}}'/></li>
<li><img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/nines-in-quinary/bd86e5de4b763ed3e8f879c79257b49f.png' alt='\mbox{\footnotesize{\displaystyle{2^2 \equiv 2 \cdot 2^1 \pmod{5} \equiv 4 \pmod{5}}}}'/></li>
<li><img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/nines-in-quinary/715e6459f2949e2cf73255a079889853.png' alt='\mbox{\footnotesize{\displaystyle{2^3 \equiv 2 \cdot 2^2 \pmod{5} \equiv 3 \pmod{5}}}}'/></li>
<li><img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/nines-in-quinary/10ad84eeb719ec93088e41889406aa18.png' alt='\mbox{\footnotesize{\displaystyle{2^4 \equiv 2 \cdot 2^3 \pmod{5} \equiv 1 \pmod{5}}}}'/></li>
<li><img class='align_middle' src='http://www.exploringbinary.com/wp-content/uploads/latexrender/pictures/nines-in-quinary/773a37ffa2b16b2677c671c9a645edbc.png' alt='\mbox{\footnotesize{\displaystyle{2^5 \equiv 2 \cdot 2^4 \pmod{5} \equiv 2 \pmod{5}}}}'/></li>
<li>&#8230;</li>
</ul>
<p>This shows the numbers 2<sup>n</sup> (n &ge; 1) mod 5 cycle through the ending digits 2, 4, 3, and 1. This means that the numbers 2<sup>n</sup> &#8211; 1 cycle through the ending digits 1, 3, 2, and 0. The digit 4 is not on the list!</p>
<h2>Nonnegative Powers of Ten in Quinary</h2>
<p>In my article &ldquo;<a title="Read Rick Regan's Article &ldquo;A Pattern in Powers of Ten and Their Binary Equivalents&rdquo;" href="http://www.exploringbinary.com/a-pattern-in-powers-of-ten-and-their-binary-equivalents/">A Pattern in Powers of Ten and Their Binary Equivalents</a>&rdquo;, I showed that the trailing digits of nonnegative powers of ten, in binary, match the power of ten; in other words, a 1 is followed by n trailing 0s. For example, 100<sub>10</sub> = 1100100<sub>2</sub>.</p>
<p>A similar, though slightly weaker property, holds for nonnegative powers of ten in quinary: 10<sup>n</sup> ends with n 0s. A nonnegative power of ten is a multiple of a power of two and a power of five: 10<sup>n</sup> =  2<sup>n</sup> * 5<sup>n</sup>. A power of two in base 5 ends in 1, 2, 3, or 4 &#8212; never 0 &#8212; as I showed above. When you multiply a power of two by a power of five, you shift the power of two left by n places in base 5, which adds n trailing 0s. So the quinary representation ends with a nonzero digit followed by n 0s &#8212; exactly n trailing 0s!</p>
<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/nines-in-quinary/">Nines in Quinary</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.exploringbinary.com/nines-in-quinary/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Finding Numbers That Are Palindromic In Multiple Bases</title>
		<link>http://www.exploringbinary.com/finding-numbers-that-are-palindromic-in-multiple-bases/</link>
		<comments>http://www.exploringbinary.com/finding-numbers-that-are-palindromic-in-multiple-bases/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 04:36:02 +0000</pubDate>
		<dc:creator>Rick Regan</dc:creator>
				<category><![CDATA[Binary numbers]]></category>
		<category><![CDATA[Binary integers]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Convert to binary]]></category>
		<category><![CDATA[Convert to decimal]]></category>

		<guid isPermaLink="false">http://www.exploringbinary.com/?p=246</guid>
		<description><![CDATA[A palindromic number, or number palindrome, is a number like 74347, which is the same written forward and backward. A number can be palindromic in any base, not just decimal. For example, 101101 is a palindrome in binary. A number can also be palindromic in more than one base, like decimal 719848917, which is 101010111010000000010111010101 [...]<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/finding-numbers-that-are-palindromic-in-multiple-bases/">Finding Numbers That Are Palindromic In Multiple Bases</a></p>
]]></description>
			<content:encoded><![CDATA[<p>A <a title="Wikipedia article defining palindromic number" href="http://en.wikipedia.org/wiki/Palindromic_number">palindromic number</a>, or number palindrome, is a number like 74347, which is the same written forward and backward.</p>
<p>A number can be palindromic in any base, not just decimal. For example, 101101 is a palindrome in binary. A number can also be palindromic in <em>more</em> than one base, like decimal 719848917, which is 101010111010000000010111010101 in binary and 5272002725 in octal.</p>
<p>An efficient way to find palindromes in a single base is to generate them, iterating through each integer and constructing palindromes from them. An efficient way to find numbers that are palindromic in <em>multiple</em> bases is to take a palindrome in one base and test if it’s a palindrome in one or more additional bases.</p>
<p>In this article, I&#8217;ll show you C code I wrote that finds multi-base numeric palindromes. I used this code to generate tables of numbers that are palindromic in decimal and binary, decimal and hexadecimal, and decimal and octal. I also used this code to solve <a title="Project Euler Problem 36 Description" href="http://projecteuler.net/index.php?section=problems&amp;id=36">Euler problem 36</a>, which asks for the sum of all numbers, less than one million, that are palindromic in decimal and binary.</p>
<p><span id="more-246"></span></p>
<h2>Checking Whether a Number is a Palindrome</h2>
<p>In general, a palindrome can be any string of characters; for example, &#8220;j4$4j&#8221;, &#8220;radar&#8221;, and &#8220;9009&#8221;. The algorithm to check whether a string is palindromic is simple: just reverse the string and compare it to itself. </p>
<p>If you&#8217;re interested only in number palindromes, you can use a more efficient, numeric algorithm instead of a string-based one. Here&#8217;s how it works:</p>
<ol>
<li>Convert the integer to be checked from a string to <a href="http://www.exploringbinary.com/base-conversion-in-php-using-built-in-functions/" title="Read Rick Regan's Article &ldquo;Base Conversion In PHP Using Built-In Functions&rdquo;">numeric binary</a>; for example, using strtol(), scanf(), or simply, a compiler constant.</li>
<li>Isolate the digits of the numeric binary value by repeatedly dividing it by the number&#8217;s base.</li>
<li>Construct, from the isolated digits, a new numeric binary integer that represents the original number written in reverse.</li>
<li>Compare the original number to the reversed number &#8212; if they are equal, the number is a palindrome.</li>
</ol>
<p>Here is a C function that implements steps 2 through 4 (step 1, the conversion of the string to numeric binary, is done outside this function, if necessary) &#8212; it is my implementation of an algorithm that appears several places on the Web (for example, at <a title="Stack Overflow Page About Checking for Numeric Palindromes" href="http://stackoverflow.com/questions/199184/how-do-i-check-if-a-number-is-a-palindrome">stackoverflow.com</a>):</p>
<pre>
int <strong>isPalindrome</strong>(unsigned long long number, unsigned char base)
{
 unsigned long long forward = number;
 unsigned long long reversed = 0;
 unsigned char digit;

 while (number > 0)
 {
  digit = number % base;
  reversed = reversed * base + digit;
  number = number / base;
 }
 return (forward == reversed);
}
</pre>
<p>This function combines two base conversion algorithms: the <strong><em>numeric binary integer to string</em></strong> algorithm and the <strong><em>string to numeric binary integer</em></strong> algorithm. The &#8220;numeric to string&#8221; algorithm isolates digits of a binary integer and appends them to a string, from least to most significant digit. The &#8220;string to numeric&#8221; algorithm isolates digits of a string and sums their place values in a binary integer, from most to least significant digit. If you fuse the two together, pipelining the digits from the &#8220;numeric to string&#8221; algorithm to the &#8220;string to numeric&#8221; algorithm, you reverse the original number &#8212; without requiring an intermediate string!</p>
<p>Single-digit numbers, including 0, are trivially palindromic, so this function will classify them as such.</p>
<h2>Generating Number Palindromes</h2>
<p>For any positive integer in base b, b+1 palindromes can be made from it. For example, the following 11 decimal palindromes can be made from the number 1: 11, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191. There is one even length palindrome, and b odd length palindromes &#8212; one per base b digit.</p>
<div class="wp-caption aligncenter" style="width: 147px"><img src="http://www.exploringbinary.com/wp-content/uploads/decimal_palindromes_from_1.png" alt="Decimal Palindromes Generated from the Number 1" width="137" height="300"/><p class="wp-caption-text">Decimal Palindromes Generated from the Number 1</p></div>
<p>Here is a C function that generates palindromes in this manner:</p>
<pre>
void <strong>makePalindromes</strong>(
       unsigned long long number,
       unsigned char base,
       unsigned long long* palindromes)
{
 /* Returns an array of size base+1 palindrome numbers (one even
    length palindrome followed by 'base' odd length palindromes) */

 unsigned long long upper = number;
 unsigned long long lower = 0;
 unsigned char digit;
 unsigned int i;
 unsigned long long power = 1;

 /* Form upper and lower portions of the new palindromes */
 while (number > 0)
 {
  upper = upper * base;  /* Shift left for each digit */
  digit = number % base;
  lower = lower * base + digit;
  number = number / base;
  power*=base;
 }

 /* Construct the even length palindrome */
 palindromes[0] = upper + lower;

 /* Construct the odd length palindromes */
 palindromes[1] = upper * base + lower; /* Middle digit: 0 */
 for (i=1; i&lt;base; i++)
 {
  palindromes[i+1] = palindromes[1] + i*power;/* Middle digit: i */
 }
}
</pre>
<p>The core of palindrome creation is the same as palindrome checking: a number must be reversed. However, instead of comparing the reversed number to the original, the reversed number is &#8220;concatenated&#8221; to the original. Mathematically, the original number is shifted left by a power of the base, becoming the upper portion of the palindrome; the reversed number is then added in to become the lower portion.</p>
<p>This function generates palindromes <strong><em>out of numeric order</em></strong> &#8212; odd length palindromes are one digit longer than their corresponding even length ones. And, perhaps not intuitively, it will make single-digit palindromes &#8212; all of them &#8212; when called with the number 0. This is despite the algorithm&#8217;s &#8220;upper/lower portion&#8221; and &#8220;even/odd length&#8221; concepts not fitting single-digit numbers &#8212; the computations work out regardless. There&#8217;s one catch though: <strong><em>0 is generated twice</em></strong>.</p>
<p>Be aware that, as unsigned long longs, palindromes cannot exceed 2<sup>64</sup> &#8211; 1. This means that the maximum number from which you can make palindromes is less than 2<sup>32</sup>. How much less depends on the base of the number.</p>
<h2>Finding Multi-Base Palindromes</h2>
<p>You can combine the functions <em>makePalindromes()</em> and <em>isPalindrome()</em> to make an efficient search for palindromes in multiple bases. This function does so for two bases:</p>
<pre>
void <strong>find_multi_base_palindromes</strong>(
       unsigned char base1,
       unsigned char base2,
       unsigned long long max_number,
       unsigned long long* multi_base_palindromes,
       unsigned int* multi_base_count)
{
 unsigned int i;
 unsigned long long counter = 0;
 unsigned long long* base1_palindromes;
 unsigned int max_palindromes = *multi_base_count;

 base1_palindromes = (unsigned long long*)
    malloc((base1+1)*sizeof(unsigned long long));

 *multi_base_count = 0;
 while (1)
 {
  /* Construct palindromes in base1 */
  <strong>makePalindromes</strong>(counter,base1,base1_palindromes);

  if (base1_palindromes[0] > max_number)
    break; /* Quit when even palindrome exceeds max */

  /* Test if base1 palindromes are also palindromic in base2 */
  for (i=0; i &lt;= base1; i++)
  {
   if (base1_palindromes[i] > max_number)
     break; /* Exit &quot;for&quot; loop if (odd) palindrome exceeds max */

   if (<strong>isPalindrome</strong>(base1_palindromes[i],base2))
   {
    if (*multi_base_count == max_palindromes)
      assert(0); /* Error: not enough room in array */
    else
    {
     multi_base_palindromes[*multi_base_count] =
       base1_palindromes[i];
     (*multi_base_count)++;
    }
   }
  }
  counter++;
 }
}
</pre>
<p>This function constructs palindromes repeatedly, from a counter that is incremented after each iteration. Since <em>makePalindromes()</em> generates palindromes out of order, knowing when to stop is a little tricky. The easy stopping case is when an even length palindrome exceeds the requested maximum &#8212; no palindromes beyond that can be smaller. The more difficult case is checking the odd length palindromes. Once one of them, from a given set, exceeds the requested maximum, the rest of that set&#8217;s palindromes do not have to be checked. However, checking must proceed to the next set of palindromes.</p>
<p>The parameter <em>multi_base_count</em> is input/output. On input, it represents the maximum number of palindromes the output array can hold. On output, it holds the number of palindromes found.</p>
<h2>Tables of Multi-Base Palindromes</h2>
<p>Using calls to <em>find_multi_base_palindromes()</em>, I created tables of multi-base palindromes in the following combinations:</p>
<ul>
<li>Decimal and binary</li>
<li>Decimal and hexadecimal</li>
<li>Decimal and octal</li>
</ul>
<p>I used additional code (not shown) to sort the palindromes, remove the duplicate 0, and print them in various bases.</p>
<p>Each respective table lists all copalindromic numbers less than 10<sup>12</sup>. The list of palindromes in each table took <strong>6 seconds or less to find</strong> &#8212; on an Intel 1.60 GHz, Core Duo T2050 processor running Windows XP.</p>
<h3><a name="decimal-binary-palindromes"></a>Palindromes in Decimal and Binary</h3>
<p>Here are all 39 decimal/binary palindromes less than 10<sup>12</sup>:</p>
<table class="center" border="1" summary="Copalindromic numbers (decimal and binary) less than 10^12">
<caption><strong>Decimal/Binary Palindromes</strong></caption>
<tbody>
<tr>
<th class="center">Decimal</th>
<th class="center">Binary</th>
</tr>
<tr>
<td class="right">0<sub>10</sub></td>
<td class="right">0<sub>2</sub></td>
</tr>
<tr>
<td class="right">1<sub>10</sub></td>
<td class="right">1<sub>2</sub></td>
</tr>
<tr>
<td class="right">3<sub>10</sub></td>
<td class="right">11<sub>2</sub></td>
</tr>
<tr>
<td class="right">5<sub>10</sub></td>
<td class="right">101<sub>2</sub></td>
</tr>
<tr>
<td class="right">7<sub>10</sub></td>
<td class="right">111<sub>2</sub></td>
</tr>
<tr>
<td class="right">9<sub>10</sub></td>
<td class="right">1001<sub>2</sub></td>
</tr>
<tr>
<td class="right">33<sub>10</sub></td>
<td class="right">100001<sub>2</sub></td>
</tr>
<tr>
<td class="right">99<sub>10</sub></td>
<td class="right">1100011<sub>2</sub></td>
</tr>
<tr>
<td class="right">313<sub>10</sub></td>
<td class="right">100111001<sub>2</sub></td>
</tr>
<tr>
<td class="right">585<sub>10</sub></td>
<td class="right">1001001001<sub>2</sub></td>
</tr>
<tr>
<td class="right">717<sub>10</sub></td>
<td class="right">1011001101<sub>2</sub></td>
</tr>
<tr>
<td class="right">7447<sub>10</sub></td>
<td class="right">1110100010111<sub>2</sub></td>
</tr>
<tr>
<td class="right">9009<sub>10</sub></td>
<td class="right">10001100110001<sub>2</sub></td>
</tr>
<tr>
<td class="right">15351<sub>10</sub></td>
<td class="right">11101111110111<sub>2</sub></td>
</tr>
<tr>
<td class="right">32223<sub>10</sub></td>
<td class="right">111110111011111<sub>2</sub></td>
</tr>
<tr>
<td class="right">39993<sub>10</sub></td>
<td class="right">1001110000111001<sub>2</sub></td>
</tr>
<tr>
<td class="right">53235<sub>10</sub></td>
<td class="right">1100111111110011<sub>2</sub></td>
</tr>
<tr>
<td class="right">53835<sub>10</sub></td>
<td class="right">1101001001001011<sub>2</sub></td>
</tr>
<tr>
<td class="right">73737<sub>10</sub></td>
<td class="right">10010000000001001<sub>2</sub></td>
</tr>
<tr>
<td class="right">585585<sub>10</sub></td>
<td class="right">10001110111101110001<sub>2</sub></td>
</tr>
<tr>
<td class="right">1758571<sub>10</sub></td>
<td class="right">110101101010101101011<sub>2</sub></td>
</tr>
<tr>
<td class="right">1934391<sub>10</sub></td>
<td class="right">111011000010000110111<sub>2</sub></td>
</tr>
<tr>
<td class="right">1979791<sub>10</sub></td>
<td class="right">111100011010110001111<sub>2</sub></td>
</tr>
<tr>
<td class="right">3129213<sub>10</sub></td>
<td class="right">1011111011111101111101<sub>2</sub></td>
</tr>
<tr>
<td class="right">5071705<sub>10</sub></td>
<td class="right">10011010110001101011001<sub>2</sub></td>
</tr>
<tr>
<td class="right">5259525<sub>10</sub></td>
<td class="right">10100000100000100000101<sub>2</sub></td>
</tr>
<tr>
<td class="right">5841485<sub>10</sub></td>
<td class="right">10110010010001001001101<sub>2</sub></td>
</tr>
<tr>
<td class="right">13500531<sub>10</sub></td>
<td class="right">110011100000000001110011<sub>2</sub></td>
</tr>
<tr>
<td class="right">719848917<sub>10</sub></td>
<td class="right">101010111010000000010111010101<sub>2</sub></td>
</tr>
<tr>
<td class="right">910373019<sub>10</sub></td>
<td class="right">110110010000110011000010011011<sub>2</sub></td>
</tr>
<tr>
<td class="right">939474939<sub>10</sub></td>
<td class="right">110111111111110011111111111011<sub>2</sub></td>
</tr>
<tr>
<td class="right">1290880921<sub>10</sub></td>
<td class="right">1001100111100010100011110011001<sub>2</sub></td>
</tr>
<tr>
<td class="right">7451111547<sub>10</sub></td>
<td class="right">110111100000111101111000001111011<sub>2</sub></td>
</tr>
<tr>
<td class="right">10050905001<sub>10</sub></td>
<td class="right">1001010111000101001010001110101001<sub>2</sub></td>
</tr>
<tr>
<td class="right">18462126481<sub>10</sub></td>
<td class="right">10001001100011011011011000110010001<sub>2</sub></td>
</tr>
<tr>
<td class="right">32479297423<sub>10</sub></td>
<td class="right">11110001111111010101011111110001111<sub>2</sub></td>
</tr>
<tr>
<td class="right">75015151057<sub>10</sub></td>
<td class="right">1000101110111010000000101110111010001<sub>2</sub></td>
</tr>
<tr>
<td class="right">110948849011<sub>10</sub></td>
<td class="right">1100111010101000100010001010101110011<sub>2</sub></td>
</tr>
<tr>
<td class="right">136525525631<sub>10</sub></td>
<td class="right">1111111001001100011100011001001111111<sub>2</sub></td>
</tr>
</tbody>
</table>
<p><strong><em>Observe</em></strong>: Palindromes in binary, except 0 itself, cannot end in 0 &#8212; leading 0s are not counted as part of a palindrome. This means that all binary palindromes are odd numbers. This also means that any number in a base copalindromic with binary is odd, and thus must start with an odd-valued digit.</p>
<p>I used the following call to generate the decimal/binary table:</p>
<pre>
 <strong>find_multi_base_palindromes</strong>
   (2,10,999999999999ULL,palindromes,&amp;count);
</pre>
<p>Swapping bases 2 and 10 gives the same results, but putting base 2 first makes it run faster. No even palindromes will be generated and thus not needlessly checked!</p>
<h3>Palindromes in Decimal and Hexadecimal</h3>
<p>Here are all 53 decimal/hexadecimal palindromes less than 10<sup>12</sup>:</p>
<table class="center" border="1" summary="Copalindromic numbers (decimal and hexadecimal) less than 10^12">
<caption><strong>Decimal/Hexadecimal Palindromes</strong></caption>
<tbody>
<tr>
<th class="center">Decimal</th>
<th class="center">Hexadecimal </th>
</tr>
<tr>
<td class="right">0<sub>10</sub></td>
<td class="right">0<sub>16</sub></td>
</tr>
<tr>
<td class="right">1<sub>10</sub></td>
<td class="right">1<sub>16</sub></td>
</tr>
<tr>
<td class="right">2<sub>10</sub></td>
<td class="right">2<sub>16</sub></td>
</tr>
<tr>
<td class="right">3<sub>10</sub></td>
<td class="right">3<sub>16</sub></td>
</tr>
<tr>
<td class="right">4<sub>10</sub></td>
<td class="right">4<sub>16</sub></td>
</tr>
<tr>
<td class="right">5<sub>10</sub></td>
<td class="right">5<sub>16</sub></td>
</tr>
<tr>
<td class="right">6<sub>10</sub></td>
<td class="right">6<sub>16</sub></td>
</tr>
<tr>
<td class="right">7<sub>10</sub></td>
<td class="right">7<sub>16</sub></td>
</tr>
<tr>
<td class="right">8<sub>10</sub></td>
<td class="right">8<sub>16</sub></td>
</tr>
<tr>
<td class="right">9<sub>10</sub></td>
<td class="right">9<sub>16</sub></td>
</tr>
<tr>
<td class="right">11<sub>10</sub></td>
<td class="right">B<sub>16</sub></td>
</tr>
<tr>
<td class="right">353<sub>10</sub></td>
<td class="right">161<sub>16</sub></td>
</tr>
<tr>
<td class="right">626<sub>10</sub></td>
<td class="right">272<sub>16</sub></td>
</tr>
<tr>
<td class="right">787<sub>10</sub></td>
<td class="right">313<sub>16</sub></td>
</tr>
<tr>
<td class="right">979<sub>10</sub></td>
<td class="right">3D3<sub>16</sub></td>
</tr>
<tr>
<td class="right">1991<sub>10</sub></td>
<td class="right">7C7<sub>16</sub></td>
</tr>
<tr>
<td class="right">3003<sub>10</sub></td>
<td class="right">BBB<sub>16</sub></td>
</tr>
<tr>
<td class="right">39593<sub>10</sub></td>
<td class="right">9AA9<sub>16</sub></td>
</tr>
<tr>
<td class="right">41514<sub>10</sub></td>
<td class="right">A22A<sub>16</sub></td>
</tr>
<tr>
<td class="right">90209<sub>10</sub></td>
<td class="right">16061<sub>16</sub></td>
</tr>
<tr>
<td class="right">94049<sub>10</sub></td>
<td class="right">16F61<sub>16</sub></td>
</tr>
<tr>
<td class="right">96369<sub>10</sub></td>
<td class="right">17871<sub>16</sub></td>
</tr>
<tr>
<td class="right">98689<sub>10</sub></td>
<td class="right">18181<sub>16</sub></td>
</tr>
<tr>
<td class="right">333333<sub>10</sub></td>
<td class="right">51615<sub>16</sub></td>
</tr>
<tr>
<td class="right">512215<sub>10</sub></td>
<td class="right">7D0D7<sub>16</sub></td>
</tr>
<tr>
<td class="right">666666<sub>10</sub></td>
<td class="right">A2C2A<sub>16</sub></td>
</tr>
<tr>
<td class="right">749947<sub>10</sub></td>
<td class="right">B717B<sub>16</sub></td>
</tr>
<tr>
<td class="right">845548<sub>10</sub></td>
<td class="right">CE6EC<sub>16</sub></td>
</tr>
<tr>
<td class="right">1612161<sub>10</sub></td>
<td class="right">189981<sub>16</sub></td>
</tr>
<tr>
<td class="right">2485842<sub>10</sub></td>
<td class="right">25EE52<sub>16</sub></td>
</tr>
<tr>
<td class="right">5614165<sub>10</sub></td>
<td class="right">55AA55<sub>16</sub></td>
</tr>
<tr>
<td class="right">6487846<sub>10</sub></td>
<td class="right">62FF26<sub>16</sub></td>
</tr>
<tr>
<td class="right">9616169<sub>10</sub></td>
<td class="right">92BB29<sub>16</sub></td>
</tr>
<tr>
<td class="right">67433476<sub>10</sub></td>
<td class="right">404F404<sub>16</sub></td>
</tr>
<tr>
<td class="right">90999909<sub>10</sub></td>
<td class="right">56C8C65<sub>16</sub></td>
</tr>
<tr>
<td class="right">94355349<sub>10</sub></td>
<td class="right">59FBF95<sub>16</sub></td>
</tr>
<tr>
<td class="right">94544549<sub>10</sub></td>
<td class="right">5A2A2A5<sub>16</sub></td>
</tr>
<tr>
<td class="right">119919911<sub>10</sub></td>
<td class="right">725D527<sub>16</sub></td>
</tr>
<tr>
<td class="right">161131161<sub>10</sub></td>
<td class="right">99AAA99<sub>16</sub></td>
</tr>
<tr>
<td class="right">190080091<sub>10</sub></td>
<td class="right">B54645B<sub>16</sub></td>
</tr>
<tr>
<td class="right">241090142<sub>10</sub></td>
<td class="right">E5EBE5E<sub>16</sub></td>
</tr>
<tr>
<td class="right">247969742<sub>10</sub></td>
<td class="right">EC7B7CE<sub>16</sub></td>
</tr>
<tr>
<td class="right">26896769862<sub>10</sub></td>
<td class="right">6432C2346<sub>16</sub></td>
</tr>
<tr>
<td class="right">28586268582<sub>10</sub></td>
<td class="right">6A7DFD7A6<sub>16</sub></td>
</tr>
<tr>
<td class="right">28779897782<sub>10</sub></td>
<td class="right">6B36A63B6<sub>16</sub></td>
</tr>
<tr>
<td class="right">30144644103<sub>10</sub></td>
<td class="right">704C2C407<sub>16</sub></td>
</tr>
<tr>
<td class="right">32442924423<sub>10</sub></td>
<td class="right">78DBFBD87<sub>16</sub></td>
</tr>
<tr>
<td class="right">39762526793<sub>10</sub></td>
<td class="right">942080249<sub>16</sub></td>
</tr>
<tr>
<td class="right">43836363834<sub>10</sub></td>
<td class="right">A34D9D43A<sub>16</sub></td>
</tr>
<tr>
<td class="right">45961216954<sub>10</sub></td>
<td class="right">AB38083BA<sub>16</sub></td>
</tr>
<tr>
<td class="right">51113531115<sub>10</sub></td>
<td class="right">BE69A96EB<sub>16</sub></td>
</tr>
<tr>
<td class="right">56702120765<sub>10</sub></td>
<td class="right">D33B5B33D<sub>16</sub></td>
</tr>
<tr>
<td class="right">390189981093<sub>10</sub></td>
<td class="right">5AD9229DA5<sub>16</sub></td>
</tr>
</tbody>
</table>
<h3>Palindromes in Decimal and Octal</h3>
<p>Here are all 45 decimal/octal palindromes less than 10<sup>12</sup>:</p>
<table class="center" border="1" summary="Copalindromic numbers (decimal and octal) less than 10^12">
<caption><strong>Decimal/Octal Palindromes</strong></caption>
<tbody>
<tr>
<th class="center">Decimal</th>
<th class="center">Octal</th>
</tr>
<tr>
<td class="right">0<sub>10</sub></td>
<td class="right">0<sub>8</sub></td>
</tr>
<tr>
<td class="right">1<sub>10</sub></td>
<td class="right">1<sub>8</sub></td>
</tr>
<tr>
<td class="right">2<sub>10</sub></td>
<td class="right">2<sub>8</sub></td>
</tr>
<tr>
<td class="right">3<sub>10</sub></td>
<td class="right">3<sub>8</sub></td>
</tr>
<tr>
<td class="right">4<sub>10</sub></td>
<td class="right">4<sub>8</sub></td>
</tr>
<tr>
<td class="right">5<sub>10</sub></td>
<td class="right">5<sub>8</sub></td>
</tr>
<tr>
<td class="right">6<sub>10</sub></td>
<td class="right">6<sub>8</sub></td>
</tr>
<tr>
<td class="right">7<sub>10</sub></td>
<td class="right">7<sub>8</sub></td>
</tr>
<tr>
<td class="right">9<sub>10</sub></td>
<td class="right">11<sub>8</sub></td>
</tr>
<tr>
<td class="right">121<sub>10</sub></td>
<td class="right">171<sub>8</sub></td>
</tr>
<tr>
<td class="right">292<sub>10</sub></td>
<td class="right">444<sub>8</sub></td>
</tr>
<tr>
<td class="right">333<sub>10</sub></td>
<td class="right">515<sub>8</sub></td>
</tr>
<tr>
<td class="right">373<sub>10</sub></td>
<td class="right">565<sub>8</sub></td>
</tr>
<tr>
<td class="right">414<sub>10</sub></td>
<td class="right">636<sub>8</sub></td>
</tr>
<tr>
<td class="right">585<sub>10</sub></td>
<td class="right">1111<sub>8</sub></td>
</tr>
<tr>
<td class="right">3663<sub>10</sub></td>
<td class="right">7117<sub>8</sub></td>
</tr>
<tr>
<td class="right">8778<sub>10</sub></td>
<td class="right">21112<sub>8</sub></td>
</tr>
<tr>
<td class="right">13131<sub>10</sub></td>
<td class="right">31513<sub>8</sub></td>
</tr>
<tr>
<td class="right">13331<sub>10</sub></td>
<td class="right">32023<sub>8</sub></td>
</tr>
<tr>
<td class="right">26462<sub>10</sub></td>
<td class="right">63536<sub>8</sub></td>
</tr>
<tr>
<td class="right">26662<sub>10</sub></td>
<td class="right">64046<sub>8</sub></td>
</tr>
<tr>
<td class="right">30103<sub>10</sub></td>
<td class="right">72627<sub>8</sub></td>
</tr>
<tr>
<td class="right">30303<sub>10</sub></td>
<td class="right">73137<sub>8</sub></td>
</tr>
<tr>
<td class="right">207702<sub>10</sub></td>
<td class="right">625526<sub>8</sub></td>
</tr>
<tr>
<td class="right">628826<sub>10</sub></td>
<td class="right">2314132<sub>8</sub></td>
</tr>
<tr>
<td class="right">660066<sub>10</sub></td>
<td class="right">2411142<sub>8</sub></td>
</tr>
<tr>
<td class="right">1496941<sub>10</sub></td>
<td class="right">5553555<sub>8</sub></td>
</tr>
<tr>
<td class="right">1935391<sub>10</sub></td>
<td class="right">7304037<sub>8</sub></td>
</tr>
<tr>
<td class="right">1970791<sub>10</sub></td>
<td class="right">7411147<sub>8</sub></td>
</tr>
<tr>
<td class="right">4198914<sub>10</sub></td>
<td class="right">20011002<sub>8</sub></td>
</tr>
<tr>
<td class="right">55366355<sub>10</sub></td>
<td class="right">323151323<sub>8</sub></td>
</tr>
<tr>
<td class="right">130535031<sub>10</sub></td>
<td class="right">761747167<sub>8</sub></td>
</tr>
<tr>
<td class="right">532898235<sub>10</sub></td>
<td class="right">3760660673<sub>8</sub></td>
</tr>
<tr>
<td class="right">719848917<sub>10</sub></td>
<td class="right">5272002725<sub>8</sub></td>
</tr>
<tr>
<td class="right">799535997<sub>10</sub></td>
<td class="right">5751771575<sub>8</sub></td>
</tr>
<tr>
<td class="right">1820330281<sub>10</sub></td>
<td class="right">15440004451<sub>8</sub></td>
</tr>
<tr>
<td class="right">2464554642<sub>10</sub></td>
<td class="right">22271417222<sub>8</sub></td>
</tr>
<tr>
<td class="right">4424994244<sub>10</sub></td>
<td class="right">40760006704<sub>8</sub></td>
</tr>
<tr>
<td class="right">4480880844<sub>10</sub></td>
<td class="right">41305150314<sub>8</sub></td>
</tr>
<tr>
<td class="right">4637337364<sub>10</sub></td>
<td class="right">42432023424<sub>8</sub></td>
</tr>
<tr>
<td class="right">20855555802<sub>10</sub></td>
<td class="right">233305503332<sub>8</sub></td>
</tr>
<tr>
<td class="right">94029892049<sub>10</sub></td>
<td class="right">1274447444721<sub>8</sub></td>
</tr>
<tr>
<td class="right">94466666449<sub>10</sub></td>
<td class="right">1277651567721<sub>8</sub></td>
</tr>
<tr>
<td class="right">294378873492<sub>10</sub></td>
<td class="right">4221226221224<sub>8</sub></td>
</tr>
<tr>
<td class="right">390894498093<sub>10</sub></td>
<td class="right">5540310130455<sub>8</sub></td>
</tr>
</tbody>
</table>
<h3>Palindromes In Decimal and Two Other Bases</h3>
<p>I searched for palindromes in the following three-base combinations, using a modifed version of <em>find_multi_base_palindromes()</em> (I added a parameter called <em>base3</em> and an extra palindrome check):</p>
<ul>
<li>Decimal, binary, and hexadecimal</li>
<li>Decimal, binary, and octal</li>
<li>Decimal, hexadecimal, and octal</li>
</ul>
<p>The only combination that produced multi-digit palindromes in three bases was decimal/binary/octal. I found two less than 10<sup>12</sup>:</p>
<ul>
<li>585<sub>10</sub> = 1001001001<sub>2</sub> = 1111<sub>8</sub></li>
<li>719848917<sub>10</sub> = 101010111010000000010111010101<sub>2</sub> = 5272002725<sub>8</sub></li>
</ul>
<p>In addition, I used this <a title="Table of Binary/Decimal Palindromes to 10^39 plus" href="http://bach.dynet.com/palin/">big table of binary/decimal palindromes</a> to determine that</p>
<ul>
<li><strong>There are no numbers less than 10<sup>39</sup> that are multi-digit copalindromic in decimal, binary and hexadecimal.</strong></li>
<li>The numbers 585<sub>10</sub> and 719848917<sub>10</sub> are the <strong><em>only</em></strong> numbers less than 10<sup>38</sup> that are multi-digit copalindromic in decimal, binary and octal.</li>
</ul>
<p>I simply converted each entry in that table to hex and octal &#8212; none, besides the two examples above, were palindromes in those bases.</p>
<p>(<strong>Update</strong>: I&#8217;ve written a <a href="http://www.exploringbinary.com/in-search-of-decimal-binary-hexadecimal-palindromes/" title="Read Rick Regan's Article &ldquo;In Search of Decimal/Binary/Hexadecimal Palindromes&rdquo;">program capable of searching beyond 2<sup>64</sup> for decimal/binary/hexadecimal palindromes</a>; none have been found to date.)</p>
<h2>Solution to Euler Problem 36</h2>
<p>You can use the above functions to solve <a title="Project Euler Problem 36 Description" href="http://projecteuler.net/index.php?section=problems&amp;id=36">Euler problem 36</a>. Here&#8217;s the code:</p>
<pre>
void euler36()
{
 unsigned int decimal_binary_count = 50; /* (Room to spare) */
 unsigned long long decimal_binary_palindromes[50];
 unsigned int i;
 unsigned long long sum = 0;

 <strong>find_multi_base_palindromes</strong>
   (2,10,999999,decimal_binary_palindromes,&amp;decimal_binary_count); 

 for (i=1; i &lt; decimal_binary_count; i++) /* i=1 skips dupe 0 */
   sum+=decimal_binary_palindromes[i];

 printf(&quot;The answer to Euler problem 36: %lld&#92;n&quot;,sum);
}
</pre>
<p>(I won&#8217;t do all the work for you. You&#8217;ll have to at least run this code to get the answer &#8212; that or add values manually from the <a title="Jump to section``Palindromes in Decimal and Binary''" href="http://www.exploringbinary.com/finding-numbers-that-are-palindromic-in-multiple-bases/#decimal-binary-palindromes">decimal/binary palindrome table above</a>.)</p>
<p>This function runs in well under 1 second.</p>
<h3>Application to Other Euler Problems</h3>
<p>There are other Euler problems that involve number palindromes: <a title="Project Euler Problem 4 Description" href="http://projecteuler.net/index.php?section=problems&amp;id=4">Euler problem 4</a>, <a title="Project Euler Problem 55 Description" href="http://projecteuler.net/index.php?section=problems&amp;id=55">Euler problem 55</a>, and <a title="Project Euler Problem 125 Description" href="http://projecteuler.net/index.php?section=problems&amp;id=125">Euler problem 125</a>. Some of the above code could be used to solve them.</p>
<h2>On Manipulating Other Bases In Binary</h2>
<p>The thing I find most interesting about generating and testing palindromes numerically in software is this: conceptually, we&#8217;re manipulating numbers in different bases, but in reality, we&#8217;re representing them and calculating with them in binary.</p>
<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/finding-numbers-that-are-palindromic-in-multiple-bases/">Finding Numbers That Are Palindromic In Multiple Bases</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.exploringbinary.com/finding-numbers-that-are-palindromic-in-multiple-bases/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Visualizing Consecutive Binary Integers</title>
		<link>http://www.exploringbinary.com/visualizing-consecutive-binary-integers/</link>
		<comments>http://www.exploringbinary.com/visualizing-consecutive-binary-integers/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 01:55:22 +0000</pubDate>
		<dc:creator>Rick Regan</dc:creator>
				<category><![CDATA[Binary numbers]]></category>

		<guid isPermaLink="false">http://www.exploringbinary.com/?p=240</guid>
		<description><![CDATA[The following is a visual depiction of the binary integers 0 through 11111111: A nice pattern, right? I generated it based on the image found on page 117 of Stephen Wolfram&#8217;s &#8220;A New Kind of Science&#8221;. I&#8217;ll discuss its structure in detail in this article. A Visual Table of Binary Integers If you were to [...]<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/visualizing-consecutive-binary-integers/">Visualizing Consecutive Binary Integers</a></p>
]]></description>
			<content:encoded><![CDATA[<p>The following is a visual depiction of the binary integers 0 through 11111111:</p>
<div class="wp-caption aligncenter" style="width: 32px"><img src="http://www.exploringbinary.com/wp-content/uploads/visual-binary-table-thumbnail.png" alt="Binary Integers 0 Through 11111111" width="22" height="500"/><p class="wp-caption-text">Binary Integers 0-11111111</p></div>
<p>A nice pattern, right? I generated it based on the image found on <a title="Read Page 117 of Wolfram's Book ``A New Kind of Science''" href="http://www.wolframscience.com/nksonline/page-117">page 117 of Stephen Wolfram&#8217;s &#8220;A New Kind of Science&#8221;</a>. I&#8217;ll discuss its structure in detail in this article.</p>
<p><span id="more-240"></span></p>
<h2>A Visual Table of Binary Integers</h2>
<p>If you were to list the first 16 nonnegative binary integers in a table like this,</p>
<div class="wp-caption aligncenter" style="width: 148px"><img src="http://www.exploringbinary.com/wp-content/uploads/visual-binary-table-short.png" alt="Binary Integers 0 Through 1111" width="138" height="290"/><p class="wp-caption-text">Binary Integers 0-1111</p></div>
<p>the 0s and 1s would form a pattern, although it may be hard to see.</p>
<p>If you were to simply color in the 1 cells, the pattern would become much more obvious:</p>
<div class="wp-caption aligncenter" style="width: 148px"><img src="http://www.exploringbinary.com/wp-content/uploads/visual-binary-table-short-black.png" alt="Binary Integers 0 Through 1111" width="138" height="290"/><p class="wp-caption-text">Binary Integers 0-1111</p></div>
<p>If you were to extend the table, the pattern would become more obvious still. Here it is extended through 11111111, as depicted in the opening of this article:</p>
<div class="wp-caption aligncenter" style="width: 244px"><img src="http://www.exploringbinary.com/wp-content/uploads/visual-binary-table.png" alt="Binary Integers 0-11111111" width="234" height="4387"/><p class="wp-caption-text">Binary Integers 0-11111111</p></div>
<h2>Powers of Two Sized Patterns</h2>
<p>The overall pattern in the table is based on vertical and horizontal sub patterns. Each sub pattern is based on <a title="Read Rick Regan's Article “A Table of Nonnegative Powers of Two”" href="http://www.exploringbinary.com/a-table-of-nonnegative-powers-of-two/">nonnegative power of two</a> sized units, which is a consequence of individual binary numbers being made up of powers of two.</p>
<h3>Vertical Patterns</h3>
<p>The basic pattern in the table is vertical, in the columns. Each column alternates between 2<sup>n</sup> 0s (blanks are considered 0s) and 2<sup>n</sup> 1s, with 2<sup>n</sup> being the value of that column&#8217;s place. This gives 2<sup>n+1</sup> sized blocks of 0s followed by 1s. For example, the pattern in the ones column is 01; the pattern in the twos column is 0011; the pattern in the fours column is 00001111; etc. </p>
<p>Here are the patterns isolated for the ones through sixteens column:</p>
<div class="wp-caption aligncenter" style="width: 268px"><img src="http://www.exploringbinary.com/wp-content/uploads/visual-binary-table-vertical.png" alt="Patterns in the First Five Columns of the Binary Numbers Table" width="258" height="563"/><p class="wp-caption-text">Patterns in First 5 Columns of Table</p></div>
<p>These patterns explain the toggle frequency of a binary counter, as discussed in my article <a title="Read Rick Regan's Article “What a Binary Counter Looks and Sounds Like''" href="http://www.exploringbinary.com/what-a-binary-counter-looks-and-sounds-like/">What a Binary Counter Looks and Sounds Like</a>.</p>
<h3>Horizontal Patterns</h3>
<p>The predominant pattern in the table is horizontal, in power of two sized groups of rows. The beauty in this pattern is the nesting. The first two rows start the pattern; the next two rows repeat the first two rows and then prefix them with a 1; the next four rows repeat the prior four rows (with leading 0s filled in first) and then prefix them with a 1; etc. </p>
<p>Here are the patterns isolated for the first five groups of rows:</p>
<div class="wp-caption aligncenter" style="width: 244px"><img src="http://www.exploringbinary.com/wp-content/uploads/visual-binary-table-nesting.png" alt="Patterns in First 32 Rows of Binary Numbers Table" width="234" height="632"/><p class="wp-caption-text">Patterns in First 32 Rows of Table</p></div>
<p>In other words, each new group of rows is a copy of all prior rows with a leading 1 attached. Expressed mathematically, the group of rows 2<sup>n</sup> to 2<sup>n+1</sup> &#8211; 1 is the group of rows 0 to 2<sup>n</sup> &#8211; 1 with 2<sup>n</sup> added to the number in each row.</p>
<h3>Horizontal Symmetry</h3>
<p>If you fold the table on itself at its halfway point &#8212; for the 256 entry table, this is at the border between decimal numbers 127 and 128 &#8212; each half will be the negative, or complement, or &#8220;dual&#8221; of the other. That is, they are the same, except white and black, or 0s and 1s, are interchanged.</p>
<h2>Related Binary Art</h2>
<p>Ivars Peterson analyzes a piece of artwork by Arlene Stamp called the <a title="Ivars Peterson Analyzes the Binary Frieze" href="http://www.maa.org/mathtourist/mathtourist_07_06_07.html">Binary Frieze</a>. The Binary Frieze incorporates the imagery above, but with two minor differences: black and white are interchanged, and the table is transposed so that numbers are in columns instead of rows:</p>
<div class="wp-caption aligncenter" style="width: 510px"><img src="http://www.exploringbinary.com/wp-content/uploads/visual-binary-frieze-thumbnail.png" alt="Binary Frieze Imagery" width="500" height="22"/><p class="wp-caption-text">Binary Frieze Imagery</p></div>
<p>This image does not appear exactly this way in the Binary Frieze, but is cut up and transformed into a piece of art.  Here are three pictures of it: <a title="Arlene Stamp's Binary Frieze (Stretch)" href="http://www.ccca.ca/artists/image.html?languagePref=en&#038;url=/c/images/big/s/stamp/sta008.jpg&#038;cright=Arlene+Stamp&#038;mkey=2287&#038;link_id=263">Binary Frieze (Stretch)</a>, <a title="Arlene Stamp's Binary Frieze (Squeeze)" href="http://www.ccca.ca/artists/image.html?languagePref=en&#038;url=/c/images/big/s/stamp/sta022.jpg&#038;cright=Arlene+Stamp&#038;mkey=2288&#038;link_id=263">Binary Frieze (Squeeze)</a>, and <a title="Arlene Stamp's Binary Frieze (Swing)" href="http://www.ccca.ca/artists/image.html?languagePref=en&#038;url=/c/images/big/s/stamp/sta023.jpg&#038;cright=Arlene+Stamp&#038;mkey=2289&#038;link_id=263">Binary Frieze (Swing)</a>.</p>
<p>As for black and white being interchanged, here&#8217;s a different interpretation: perhaps it represents a <em>countdown</em> from 255 to 0.</p>
<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/visualizing-consecutive-binary-integers/">Visualizing Consecutive Binary Integers</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.exploringbinary.com/visualizing-consecutive-binary-integers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Decimal/Binary Conversion Table</title>
		<link>http://www.exploringbinary.com/decimal-binary-conversion-table/</link>
		<comments>http://www.exploringbinary.com/decimal-binary-conversion-table/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 20:31:18 +0000</pubDate>
		<dc:creator>Rick Regan</dc:creator>
				<category><![CDATA[Binary numbers]]></category>

		<guid isPermaLink="false">http://www.exploringbinary.com/?p=239</guid>
		<description><![CDATA[Here is a table you can use to convert small integers &#8212; integers between 0 and 255 &#8212; directly between decimal and binary (as an alternative to using a decimal/binary converter): Integers 0 to 255, in Decimal and Binary Dec Binary Dec Binary Dec Binary Dec Binary 0 0 64 1000000 128 10000000 192 11000000 [...]<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/decimal-binary-conversion-table/">Decimal/Binary Conversion Table</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Here is a table you can use to convert small integers &#8212; integers between 0 and 255 &#8212; directly between decimal and binary (as an alternative to using a <a title="Rick Regan's Decimal/Binary Converter" href="http://www.exploringbinary.com/binary-converter/">decimal/binary converter</a>):</p>
<p><span id="more-239"></span></p>
<table class="center" border="1" summary="Integers 0 to 255, in Decimal and Binary">
<caption><strong>Integers 0 to 255, in Decimal and Binary</strong></caption>
<tbody>
<tr>
<th class="center"><abbr title="Decimal">Dec</abbr></th>
<th class="center">Binary</th>
<th class="vertical_border"></th>
<th class="center"><abbr title="Decimal">Dec</abbr></th>
<th class="center">Binary</th>
<th class="vertical_border"></th>
<th class="center"><abbr title="Decimal">Dec</abbr></th>
<th class="center">Binary</th>
<th class="vertical_border"></th>
<th class="center"><abbr title="Decimal">Dec</abbr></th>
<th class="center">Binary</th>
</tr>
<tr>
<td class="right">0</td>
<td class="right">0</td>
<td class="vertical_border"></td>
<td class="right">64</td>
<td class="right">1000000</td>
<td class="vertical_border"></td>
<td class="right">128</td>
<td class="right">10000000</td>
<td class="vertical_border"></td>
<td class="right">192</td>
<td class="right">11000000</td>
</tr>
<tr>
<td class="right">1</td>
<td class="right">1</td>
<td class="vertical_border"></td>
<td class="right">65</td>
<td class="right">1000001</td>
<td class="vertical_border"></td>
<td class="right">129</td>
<td class="right">10000001</td>
<td class="vertical_border"></td>
<td class="right">193</td>
<td class="right">11000001</td>
</tr>
<tr>
<td class="right">2</td>
<td class="right">10</td>
<td class="vertical_border"></td>
<td class="right">66</td>
<td class="right">1000010</td>
<td class="vertical_border"></td>
<td class="right">130</td>
<td class="right">10000010</td>
<td class="vertical_border"></td>
<td class="right">194</td>
<td class="right">11000010</td>
</tr>
<tr>
<td class="right">3</td>
<td class="right">11</td>
<td class="vertical_border"></td>
<td class="right">67</td>
<td class="right">1000011</td>
<td class="vertical_border"></td>
<td class="right">131</td>
<td class="right">10000011</td>
<td class="vertical_border"></td>
<td class="right">195</td>
<td class="right">11000011</td>
</tr>
<tr>
<td class="right">4</td>
<td class="right">100</td>
<td class="vertical_border"></td>
<td class="right">68</td>
<td class="right">1000100</td>
<td class="vertical_border"></td>
<td class="right">132</td>
<td class="right">10000100</td>
<td class="vertical_border"></td>
<td class="right">196</td>
<td class="right">11000100</td>
</tr>
<tr>
<td class="right">5</td>
<td class="right">101</td>
<td class="vertical_border"></td>
<td class="right">69</td>
<td class="right">1000101</td>
<td class="vertical_border"></td>
<td class="right">133</td>
<td class="right">10000101</td>
<td class="vertical_border"></td>
<td class="right">197</td>
<td class="right">11000101</td>
</tr>
<tr>
<td class="right">6</td>
<td class="right">110</td>
<td class="vertical_border"></td>
<td class="right">70</td>
<td class="right">1000110</td>
<td class="vertical_border"></td>
<td class="right">134</td>
<td class="right">10000110</td>
<td class="vertical_border"></td>
<td class="right">198</td>
<td class="right">11000110</td>
</tr>
<tr>
<td class="right">7</td>
<td class="right">111</td>
<td class="vertical_border"></td>
<td class="right">71</td>
<td class="right">1000111</td>
<td class="vertical_border"></td>
<td class="right">135</td>
<td class="right">10000111</td>
<td class="vertical_border"></td>
<td class="right">199</td>
<td class="right">11000111</td>
</tr>
<tr>
<td class="right">8</td>
<td class="right">1000</td>
<td class="vertical_border"></td>
<td class="right">72</td>
<td class="right">1001000</td>
<td class="vertical_border"></td>
<td class="right">136</td>
<td class="right">10001000</td>
<td class="vertical_border"></td>
<td class="right">200</td>
<td class="right">11001000</td>
</tr>
<tr>
<td class="right">9</td>
<td class="right">1001</td>
<td class="vertical_border"></td>
<td class="right">73</td>
<td class="right">1001001</td>
<td class="vertical_border"></td>
<td class="right">137</td>
<td class="right">10001001</td>
<td class="vertical_border"></td>
<td class="right">201</td>
<td class="right">11001001</td>
</tr>
<tr>
<td class="right">10</td>
<td class="right">1010</td>
<td class="vertical_border"></td>
<td class="right">74</td>
<td class="right">1001010</td>
<td class="vertical_border"></td>
<td class="right">138</td>
<td class="right">10001010</td>
<td class="vertical_border"></td>
<td class="right">202</td>
<td class="right">11001010</td>
</tr>
<tr>
<td class="right">11</td>
<td class="right">1011</td>
<td class="vertical_border"></td>
<td class="right">75</td>
<td class="right">1001011</td>
<td class="vertical_border"></td>
<td class="right">139</td>
<td class="right">10001011</td>
<td class="vertical_border"></td>
<td class="right">203</td>
<td class="right">11001011</td>
</tr>
<tr>
<td class="right">12</td>
<td class="right">1100</td>
<td class="vertical_border"></td>
<td class="right">76</td>
<td class="right">1001100</td>
<td class="vertical_border"></td>
<td class="right">140</td>
<td class="right">10001100</td>
<td class="vertical_border"></td>
<td class="right">204</td>
<td class="right">11001100</td>
</tr>
<tr>
<td class="right">13</td>
<td class="right">1101</td>
<td class="vertical_border"></td>
<td class="right">77</td>
<td class="right">1001101</td>
<td class="vertical_border"></td>
<td class="right">141</td>
<td class="right">10001101</td>
<td class="vertical_border"></td>
<td class="right">205</td>
<td class="right">11001101</td>
</tr>
<tr>
<td class="right">14</td>
<td class="right">1110</td>
<td class="vertical_border"></td>
<td class="right">78</td>
<td class="right">1001110</td>
<td class="vertical_border"></td>
<td class="right">142</td>
<td class="right">10001110</td>
<td class="vertical_border"></td>
<td class="right">206</td>
<td class="right">11001110</td>
</tr>
<tr>
<td class="right">15</td>
<td class="right">1111</td>
<td class="vertical_border"></td>
<td class="right">79</td>
<td class="right">1001111</td>
<td class="vertical_border"></td>
<td class="right">143</td>
<td class="right">10001111</td>
<td class="vertical_border"></td>
<td class="right">207</td>
<td class="right">11001111</td>
</tr>
<tr>
<td class="right">16</td>
<td class="right">10000</td>
<td class="vertical_border"></td>
<td class="right">80</td>
<td class="right">1010000</td>
<td class="vertical_border"></td>
<td class="right">144</td>
<td class="right">10010000</td>
<td class="vertical_border"></td>
<td class="right">208</td>
<td class="right">11010000</td>
</tr>
<tr>
<td class="right">17</td>
<td class="right">10001</td>
<td class="vertical_border"></td>
<td class="right">81</td>
<td class="right">1010001</td>
<td class="vertical_border"></td>
<td class="right">145</td>
<td class="right">10010001</td>
<td class="vertical_border"></td>
<td class="right">209</td>
<td class="right">11010001</td>
</tr>
<tr>
<td class="right">18</td>
<td class="right">10010</td>
<td class="vertical_border"></td>
<td class="right">82</td>
<td class="right">1010010</td>
<td class="vertical_border"></td>
<td class="right">146</td>
<td class="right">10010010</td>
<td class="vertical_border"></td>
<td class="right">210</td>
<td class="right">11010010</td>
</tr>
<tr>
<td class="right">19</td>
<td class="right">10011</td>
<td class="vertical_border"></td>
<td class="right">83</td>
<td class="right">1010011</td>
<td class="vertical_border"></td>
<td class="right">147</td>
<td class="right">10010011</td>
<td class="vertical_border"></td>
<td class="right">211</td>
<td class="right">11010011</td>
</tr>
<tr>
<td class="right">20</td>
<td class="right">10100</td>
<td class="vertical_border"></td>
<td class="right">84</td>
<td class="right">1010100</td>
<td class="vertical_border"></td>
<td class="right">148</td>
<td class="right">10010100</td>
<td class="vertical_border"></td>
<td class="right">212</td>
<td class="right">11010100</td>
</tr>
<tr>
<td class="right">21</td>
<td class="right">10101</td>
<td class="vertical_border"></td>
<td class="right">85</td>
<td class="right">1010101</td>
<td class="vertical_border"></td>
<td class="right">149</td>
<td class="right">10010101</td>
<td class="vertical_border"></td>
<td class="right">213</td>
<td class="right">11010101</td>
</tr>
<tr>
<td class="right">22</td>
<td class="right">10110</td>
<td class="vertical_border"></td>
<td class="right">86</td>
<td class="right">1010110</td>
<td class="vertical_border"></td>
<td class="right">150</td>
<td class="right">10010110</td>
<td class="vertical_border"></td>
<td class="right">214</td>
<td class="right">11010110</td>
</tr>
<tr>
<td class="right">23</td>
<td class="right">10111</td>
<td class="vertical_border"></td>
<td class="right">87</td>
<td class="right">1010111</td>
<td class="vertical_border"></td>
<td class="right">151</td>
<td class="right">10010111</td>
<td class="vertical_border"></td>
<td class="right">215</td>
<td class="right">11010111</td>
</tr>
<tr>
<td class="right">24</td>
<td class="right">11000</td>
<td class="vertical_border"></td>
<td class="right">88</td>
<td class="right">1011000</td>
<td class="vertical_border"></td>
<td class="right">152</td>
<td class="right">10011000</td>
<td class="vertical_border"></td>
<td class="right">216</td>
<td class="right">11011000</td>
</tr>
<tr>
<td class="right">25</td>
<td class="right">11001</td>
<td class="vertical_border"></td>
<td class="right">89</td>
<td class="right">1011001</td>
<td class="vertical_border"></td>
<td class="right">153</td>
<td class="right">10011001</td>
<td class="vertical_border"></td>
<td class="right">217</td>
<td class="right">11011001</td>
</tr>
<tr>
<td class="right">26</td>
<td class="right">11010</td>
<td class="vertical_border"></td>
<td class="right">90</td>
<td class="right">1011010</td>
<td class="vertical_border"></td>
<td class="right">154</td>
<td class="right">10011010</td>
<td class="vertical_border"></td>
<td class="right">218</td>
<td class="right">11011010</td>
</tr>
<tr>
<td class="right">27</td>
<td class="right">11011</td>
<td class="vertical_border"></td>
<td class="right">91</td>
<td class="right">1011011</td>
<td class="vertical_border"></td>
<td class="right">155</td>
<td class="right">10011011</td>
<td class="vertical_border"></td>
<td class="right">219</td>
<td class="right">11011011</td>
</tr>
<tr>
<td class="right">28</td>
<td class="right">11100</td>
<td class="vertical_border"></td>
<td class="right">92</td>
<td class="right">1011100</td>
<td class="vertical_border"></td>
<td class="right">156</td>
<td class="right">10011100</td>
<td class="vertical_border"></td>
<td class="right">220</td>
<td class="right">11011100</td>
</tr>
<tr>
<td class="right">29</td>
<td class="right">11101</td>
<td class="vertical_border"></td>
<td class="right">93</td>
<td class="right">1011101</td>
<td class="vertical_border"></td>
<td class="right">157</td>
<td class="right">10011101</td>
<td class="vertical_border"></td>
<td class="right">221</td>
<td class="right">11011101</td>
</tr>
<tr>
<td class="right">30</td>
<td class="right">11110</td>
<td class="vertical_border"></td>
<td class="right">94</td>
<td class="right">1011110</td>
<td class="vertical_border"></td>
<td class="right">158</td>
<td class="right">10011110</td>
<td class="vertical_border"></td>
<td class="right">222</td>
<td class="right">11011110</td>
</tr>
<tr>
<td class="right">31</td>
<td class="right">11111</td>
<td class="vertical_border"></td>
<td class="right">95</td>
<td class="right">1011111</td>
<td class="vertical_border"></td>
<td class="right">159</td>
<td class="right">10011111</td>
<td class="vertical_border"></td>
<td class="right">223</td>
<td class="right">11011111</td>
</tr>
<tr>
<td class="right">32</td>
<td class="right">100000</td>
<td class="vertical_border"></td>
<td class="right">96</td>
<td class="right">1100000</td>
<td class="vertical_border"></td>
<td class="right">160</td>
<td class="right">10100000</td>
<td class="vertical_border"></td>
<td class="right">224</td>
<td class="right">11100000</td>
</tr>
<tr>
<td class="right">33</td>
<td class="right">100001</td>
<td class="vertical_border"></td>
<td class="right">97</td>
<td class="right">1100001</td>
<td class="vertical_border"></td>
<td class="right">161</td>
<td class="right">10100001</td>
<td class="vertical_border"></td>
<td class="right">225</td>
<td class="right">11100001</td>
</tr>
<tr>
<td class="right">34</td>
<td class="right">100010</td>
<td class="vertical_border"></td>
<td class="right">98</td>
<td class="right">1100010</td>
<td class="vertical_border"></td>
<td class="right">162</td>
<td class="right">10100010</td>
<td class="vertical_border"></td>
<td class="right">226</td>
<td class="right">11100010</td>
</tr>
<tr>
<td class="right">35</td>
<td class="right">100011</td>
<td class="vertical_border"></td>
<td class="right">99</td>
<td class="right">1100011</td>
<td class="vertical_border"></td>
<td class="right">163</td>
<td class="right">10100011</td>
<td class="vertical_border"></td>
<td class="right">227</td>
<td class="right">11100011</td>
</tr>
<tr>
<td class="right">36</td>
<td class="right">100100</td>
<td class="vertical_border"></td>
<td class="right">100</td>
<td class="right">1100100</td>
<td class="vertical_border"></td>
<td class="right">164</td>
<td class="right">10100100</td>
<td class="vertical_border"></td>
<td class="right">228</td>
<td class="right">11100100</td>
</tr>
<tr>
<td class="right">37</td>
<td class="right">100101</td>
<td class="vertical_border"></td>
<td class="right">101</td>
<td class="right">1100101</td>
<td class="vertical_border"></td>
<td class="right">165</td>
<td class="right">10100101</td>
<td class="vertical_border"></td>
<td class="right">229</td>
<td class="right">11100101</td>
</tr>
<tr>
<td class="right">38</td>
<td class="right">100110</td>
<td class="vertical_border"></td>
<td class="right">102</td>
<td class="right">1100110</td>
<td class="vertical_border"></td>
<td class="right">166</td>
<td class="right">10100110</td>
<td class="vertical_border"></td>
<td class="right">230</td>
<td class="right">11100110</td>
</tr>
<tr>
<td class="right">39</td>
<td class="right">100111</td>
<td class="vertical_border"></td>
<td class="right">103</td>
<td class="right">1100111</td>
<td class="vertical_border"></td>
<td class="right">167</td>
<td class="right">10100111</td>
<td class="vertical_border"></td>
<td class="right">231</td>
<td class="right">11100111</td>
</tr>
<tr>
<td class="right">40</td>
<td class="right">101000</td>
<td class="vertical_border"></td>
<td class="right">104</td>
<td class="right">1101000</td>
<td class="vertical_border"></td>
<td class="right">168</td>
<td class="right">10101000</td>
<td class="vertical_border"></td>
<td class="right">232</td>
<td class="right">11101000</td>
</tr>
<tr>
<td class="right">41</td>
<td class="right">101001</td>
<td class="vertical_border"></td>
<td class="right">105</td>
<td class="right">1101001</td>
<td class="vertical_border"></td>
<td class="right">169</td>
<td class="right">10101001</td>
<td class="vertical_border"></td>
<td class="right">233</td>
<td class="right">11101001</td>
</tr>
<tr>
<td class="right">42</td>
<td class="right">101010</td>
<td class="vertical_border"></td>
<td class="right">106</td>
<td class="right">1101010</td>
<td class="vertical_border"></td>
<td class="right">170</td>
<td class="right">10101010</td>
<td class="vertical_border"></td>
<td class="right">234</td>
<td class="right">11101010</td>
</tr>
<tr>
<td class="right">43</td>
<td class="right">101011</td>
<td class="vertical_border"></td>
<td class="right">107</td>
<td class="right">1101011</td>
<td class="vertical_border"></td>
<td class="right">171</td>
<td class="right">10101011</td>
<td class="vertical_border"></td>
<td class="right">235</td>
<td class="right">11101011</td>
</tr>
<tr>
<td class="right">44</td>
<td class="right">101100</td>
<td class="vertical_border"></td>
<td class="right">108</td>
<td class="right">1101100</td>
<td class="vertical_border"></td>
<td class="right">172</td>
<td class="right">10101100</td>
<td class="vertical_border"></td>
<td class="right">236</td>
<td class="right">11101100</td>
</tr>
<tr>
<td class="right">45</td>
<td class="right">101101</td>
<td class="vertical_border"></td>
<td class="right">109</td>
<td class="right">1101101</td>
<td class="vertical_border"></td>
<td class="right">173</td>
<td class="right">10101101</td>
<td class="vertical_border"></td>
<td class="right">237</td>
<td class="right">11101101</td>
</tr>
<tr>
<td class="right">46</td>
<td class="right">101110</td>
<td class="vertical_border"></td>
<td class="right">110</td>
<td class="right">1101110</td>
<td class="vertical_border"></td>
<td class="right">174</td>
<td class="right">10101110</td>
<td class="vertical_border"></td>
<td class="right">238</td>
<td class="right">11101110</td>
</tr>
<tr>
<td class="right">47</td>
<td class="right">101111</td>
<td class="vertical_border"></td>
<td class="right">111</td>
<td class="right">1101111</td>
<td class="vertical_border"></td>
<td class="right">175</td>
<td class="right">10101111</td>
<td class="vertical_border"></td>
<td class="right">239</td>
<td class="right">11101111</td>
</tr>
<tr>
<td class="right">48</td>
<td class="right">110000</td>
<td class="vertical_border"></td>
<td class="right">112</td>
<td class="right">1110000</td>
<td class="vertical_border"></td>
<td class="right">176</td>
<td class="right">10110000</td>
<td class="vertical_border"></td>
<td class="right">240</td>
<td class="right">11110000</td>
</tr>
<tr>
<td class="right">49</td>
<td class="right">110001</td>
<td class="vertical_border"></td>
<td class="right">113</td>
<td class="right">1110001</td>
<td class="vertical_border"></td>
<td class="right">177</td>
<td class="right">10110001</td>
<td class="vertical_border"></td>
<td class="right">241</td>
<td class="right">11110001</td>
</tr>
<tr>
<td class="right">50</td>
<td class="right">110010</td>
<td class="vertical_border"></td>
<td class="right">114</td>
<td class="right">1110010</td>
<td class="vertical_border"></td>
<td class="right">178</td>
<td class="right">10110010</td>
<td class="vertical_border"></td>
<td class="right">242</td>
<td class="right">11110010</td>
</tr>
<tr>
<td class="right">51</td>
<td class="right">110011</td>
<td class="vertical_border"></td>
<td class="right">115</td>
<td class="right">1110011</td>
<td class="vertical_border"></td>
<td class="right">179</td>
<td class="right">10110011</td>
<td class="vertical_border"></td>
<td class="right">243</td>
<td class="right">11110011</td>
</tr>
<tr>
<td class="right">52</td>
<td class="right">110100</td>
<td class="vertical_border"></td>
<td class="right">116</td>
<td class="right">1110100</td>
<td class="vertical_border"></td>
<td class="right">180</td>
<td class="right">10110100</td>
<td class="vertical_border"></td>
<td class="right">244</td>
<td class="right">11110100</td>
</tr>
<tr>
<td class="right">53</td>
<td class="right">110101</td>
<td class="vertical_border"></td>
<td class="right">117</td>
<td class="right">1110101</td>
<td class="vertical_border"></td>
<td class="right">181</td>
<td class="right">10110101</td>
<td class="vertical_border"></td>
<td class="right">245</td>
<td class="right">11110101</td>
</tr>
<tr>
<td class="right">54</td>
<td class="right">110110</td>
<td class="vertical_border"></td>
<td class="right">118</td>
<td class="right">1110110</td>
<td class="vertical_border"></td>
<td class="right">182</td>
<td class="right">10110110</td>
<td class="vertical_border"></td>
<td class="right">246</td>
<td class="right">11110110</td>
</tr>
<tr>
<td class="right">55</td>
<td class="right">110111</td>
<td class="vertical_border"></td>
<td class="right">119</td>
<td class="right">1110111</td>
<td class="vertical_border"></td>
<td class="right">183</td>
<td class="right">10110111</td>
<td class="vertical_border"></td>
<td class="right">247</td>
<td class="right">11110111</td>
</tr>
<tr>
<td class="right">56</td>
<td class="right">111000</td>
<td class="vertical_border"></td>
<td class="right">120</td>
<td class="right">1111000</td>
<td class="vertical_border"></td>
<td class="right">184</td>
<td class="right">10111000</td>
<td class="vertical_border"></td>
<td class="right">248</td>
<td class="right">11111000</td>
</tr>
<tr>
<td class="right">57</td>
<td class="right">111001</td>
<td class="vertical_border"></td>
<td class="right">121</td>
<td class="right">1111001</td>
<td class="vertical_border"></td>
<td class="right">185</td>
<td class="right">10111001</td>
<td class="vertical_border"></td>
<td class="right">249</td>
<td class="right">11111001</td>
</tr>
<tr>
<td class="right">58</td>
<td class="right">111010</td>
<td class="vertical_border"></td>
<td class="right">122</td>
<td class="right">1111010</td>
<td class="vertical_border"></td>
<td class="right">186</td>
<td class="right">10111010</td>
<td class="vertical_border"></td>
<td class="right">250</td>
<td class="right">11111010</td>
</tr>
<tr>
<td class="right">59</td>
<td class="right">111011</td>
<td class="vertical_border"></td>
<td class="right">123</td>
<td class="right">1111011</td>
<td class="vertical_border"></td>
<td class="right">187</td>
<td class="right">10111011</td>
<td class="vertical_border"></td>
<td class="right">251</td>
<td class="right">11111011</td>
</tr>
<tr>
<td class="right">60</td>
<td class="right">111100</td>
<td class="vertical_border"></td>
<td class="right">124</td>
<td class="right">1111100</td>
<td class="vertical_border"></td>
<td class="right">188</td>
<td class="right">10111100</td>
<td class="vertical_border"></td>
<td class="right">252</td>
<td class="right">11111100</td>
</tr>
<tr>
<td class="right">61</td>
<td class="right">111101</td>
<td class="vertical_border"></td>
<td class="right">125</td>
<td class="right">1111101</td>
<td class="vertical_border"></td>
<td class="right">189</td>
<td class="right">10111101</td>
<td class="vertical_border"></td>
<td class="right">253</td>
<td class="right">11111101</td>
</tr>
<tr>
<td class="right">62</td>
<td class="right">111110</td>
<td class="vertical_border"></td>
<td class="right">126</td>
<td class="right">1111110</td>
<td class="vertical_border"></td>
<td class="right">190</td>
<td class="right">10111110</td>
<td class="vertical_border"></td>
<td class="right">254</td>
<td class="right">11111110</td>
</tr>
<tr>
<td class="right">63</td>
<td class="right">111111</td>
<td class="vertical_border"></td>
<td class="right">127</td>
<td class="right">1111111</td>
<td class="vertical_border"></td>
<td class="right">191</td>
<td class="right">10111111</td>
<td class="vertical_border"></td>
<td class="right">255</td>
<td class="right">11111111</td>
</tr>
</tbody>
</table>
<p>There are four columns of 64 entries each, totaling 256 entries.</p>
<p>If you are using these values for storage in a computer word &#8212; for example, a byte &#8212; be sure to pad with leading 0s, as necessary.</p>
<p>By Rick Regan (Copyright &copy; 2008-2012  <a href="http://www.exploringbinary.com">Exploring Binary</a>)<br/><br/><a href="http://www.exploringbinary.com/decimal-binary-conversion-table/">Decimal/Binary Conversion Table</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.exploringbinary.com/decimal-binary-conversion-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

