<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Efficient C Tips #9 &#8211; Use lookup tables</title>
	<atom:link href="http://embeddedgurus.com/stack-overflow/2009/05/efficient-c-tips-9-use-lookup-tables/feed/" rel="self" type="application/rss+xml" />
	<link>http://embeddedgurus.com/stack-overflow/2009/05/efficient-c-tips-9-use-lookup-tables/</link>
	<description>Thoughts on embedded systems by Nigel Jones</description>
	<lastBuildDate>Sun, 06 May 2012 10:34:02 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Nigel Jones</title>
		<link>http://embeddedgurus.com/stack-overflow/2009/05/efficient-c-tips-9-use-lookup-tables/comment-page-1/#comment-231</link>
		<dc:creator>Nigel Jones</dc:creator>
		<pubDate>Fri, 05 Jun 2009 12:28:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfcdev.org/test-stack/2009/05/28/efficient-c-tips-9-use-lookup-tables/#comment-231</guid>
		<description>Yevheniy diplomatically pointed out to me (by email) that I had allocated 31 days to November. We do a lot of strange things in Maryland but alas this is not one of them.I guess it&#039;s been one of those weeks. No doubt I should just take this &lt;a href=&quot;http://www.embeddedgurus.net/stack-overflow/2009/02/first-do-no-harm.html&quot; rel=&quot;nofollow&quot;&gt;advice&lt;/a&gt; and quit on this post.</description>
		<content:encoded><![CDATA[<p>Yevheniy diplomatically pointed out to me (by email) that I had allocated 31 days to November. We do a lot of strange things in Maryland but alas this is not one of them.I guess it&#39;s been one of those weeks. No doubt I should just take this <a href="http://www.embeddedgurus.net/stack-overflow/2009/02/first-do-no-harm.html" rel="nofollow">advice</a> and quit on this post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nigel Jones</title>
		<link>http://embeddedgurus.com/stack-overflow/2009/05/efficient-c-tips-9-use-lookup-tables/comment-page-1/#comment-230</link>
		<dc:creator>Nigel Jones</dc:creator>
		<pubDate>Wed, 03 Jun 2009 16:56:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfcdev.org/test-stack/2009/05/28/efficient-c-tips-9-use-lookup-tables/#comment-230</guid>
		<description>You win the prize for spotting the deliberate mistake! Thanks for paying careful attention - I&#039;ll correct the code.</description>
		<content:encoded><![CDATA[<p>You win the prize for spotting the deliberate mistake! Thanks for paying careful attention &#8211; I&#39;ll correct the code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yevheniy Soloshenko</title>
		<link>http://embeddedgurus.com/stack-overflow/2009/05/efficient-c-tips-9-use-lookup-tables/comment-page-1/#comment-229</link>
		<dc:creator>Yevheniy Soloshenko</dc:creator>
		<pubDate>Wed, 03 Jun 2009 11:15:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfcdev.org/test-stack/2009/05/28/efficient-c-tips-9-use-lookup-tables/#comment-229</guid>
		<description>Nigel, do we need &quot;+DEC_DAYS&quot; in case of December? It will be already next year.</description>
		<content:encoded><![CDATA[<p>Nigel, do we need &quot;+DEC_DAYS&quot; in case of December? It will be already next year.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GregK</title>
		<link>http://embeddedgurus.com/stack-overflow/2009/05/efficient-c-tips-9-use-lookup-tables/comment-page-1/#comment-228</link>
		<dc:creator>GregK</dc:creator>
		<pubDate>Tue, 02 Jun 2009 22:00:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfcdev.org/test-stack/2009/05/28/efficient-c-tips-9-use-lookup-tables/#comment-228</guid>
		<description>1. Confusing!if ((year % 4 == 0) &amp;&amp; (year % 100 != 0) &#124;&#124; (year % 400 == 0)){}if (    ((year % 4 == 0) &amp;&amp; (year % 100 != 0))     &#124;&#124; (year % 400 == 0) ){}2. I would rather cut this:  (year % 400 == 0)  if we considering only current and future time. Modulo is in most cases extremly costly,  and do this with one dimention array:  day_of_year = days[month] + day;  if (month &gt; 2)  {    if ( ((year % 4 == 0) &amp;&amp; (year % 100 != 0)) &#124;&#124; /* (year % 400 == 0) */  )    {      ++day_of_year;    }  }</description>
		<content:encoded><![CDATA[<p>1. Confusing!if ((year % 4 == 0) &amp;&amp; (year % 100 != 0) || (year % 400 == 0)){}if (    ((year % 4 == 0) &amp;&amp; (year % 100 != 0))     || (year % 400 == 0) ){}2. I would rather cut this:  (year % 400 == 0)  if we considering only current and future time. Modulo is in most cases extremly costly,  and do this with one dimention array:  day_of_year = days[month] + day;  if (month &gt; 2)  {    if ( ((year % 4 == 0) &amp;&amp; (year % 100 != 0)) || /* (year % 400 == 0) */  )    {      ++day_of_year;    }  }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nigel Jones</title>
		<link>http://embeddedgurus.com/stack-overflow/2009/05/efficient-c-tips-9-use-lookup-tables/comment-page-1/#comment-227</link>
		<dc:creator>Nigel Jones</dc:creator>
		<pubDate>Thu, 28 May 2009 16:27:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfcdev.org/test-stack/2009/05/28/efficient-c-tips-9-use-lookup-tables/#comment-227</guid>
		<description>Ah yes the good old cache problem. Writing code so as to optimize cache performance is definitely one of the more challenging tasks. For example a common speed optimization is to unravel loops - which of course on some CPUs means the code is no longer completely held in cache and thus runs slower. Having said that, your point is well taken. The proof of the pudding is always in the eating.</description>
		<content:encoded><![CDATA[<p>Ah yes the good old cache problem. Writing code so as to optimize cache performance is definitely one of the more challenging tasks. For example a common speed optimization is to unravel loops &#8211; which of course on some CPUs means the code is no longer completely held in cache and thus runs slower. Having said that, your point is well taken. The proof of the pudding is always in the eating.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Uhmmmm</title>
		<link>http://embeddedgurus.com/stack-overflow/2009/05/efficient-c-tips-9-use-lookup-tables/comment-page-1/#comment-226</link>
		<dc:creator>Uhmmmm</dc:creator>
		<pubDate>Thu, 28 May 2009 16:12:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfcdev.org/test-stack/2009/05/28/efficient-c-tips-9-use-lookup-tables/#comment-226</guid>
		<description>I would just add a comment about blowing the data cache with huge lookup tables.  It can happen, and in those cases, the extra calculation may be faster than going to memory.  Just like blindly coding the algorithm isn&#039;t optimal, neither is blindly trusting a LUT to be optimal.  As always, the code should be benchmarked.</description>
		<content:encoded><![CDATA[<p>I would just add a comment about blowing the data cache with huge lookup tables.  It can happen, and in those cases, the extra calculation may be faster than going to memory.  Just like blindly coding the algorithm isn&#8217;t optimal, neither is blindly trusting a LUT to be optimal.  As always, the code should be benchmarked.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

