<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Komap's Blog</title>
	<atom:link href="http://komap.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://komap.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Sat, 10 Dec 2011 12:54:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='komap.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Komap's Blog</title>
		<link>http://komap.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://komap.wordpress.com/osd.xml" title="Komap&#039;s Blog" />
	<atom:link rel='hub' href='http://komap.wordpress.com/?pushpress=hub'/>
		<item>
		<title>convert 16 bit &#8220;half float&#8221; to 32 bit float</title>
		<link>http://komap.wordpress.com/2011/12/01/convert-16-bit-half-float-to-32-bit-float/</link>
		<comments>http://komap.wordpress.com/2011/12/01/convert-16-bit-half-float-to-32-bit-float/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 17:22:04 +0000</pubDate>
		<dc:creator>komap</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[bits]]></category>
		<category><![CDATA[floatingpont]]></category>

		<guid isPermaLink="false">http://komap.wordpress.com/?p=358</guid>
		<description><![CDATA[See also: IEEE 754 single-precision binary floating-point format: binary32 16-bit Floating-Point Rules<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=358&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>See also:<br />
<a href="http://en.wikipedia.org/wiki/Single_precision_floating-point_format" title="IEEE 754 single-precision binary floating-point format: binary32">IEEE 754 single-precision binary floating-point format: binary32</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/cc308050(v=vs.85).aspx" title="16-bit Floating-Point Rules">16-bit Floating-Point Rules</a></p>
<p><pre class="brush: cpp;">
float convert16to32float(unsigned int Xi_Value)
{ 
 //TODO:test, imporve, optimize..
  int exp = (Xi_Value&gt;&gt;10) &amp; 0x01f;
  float g=0;
  unsigned int *i=(unsigned int *) &amp; g;
  Xi_Value &amp;= 0xffff;
  *i=0;
  *i |= Xi_Value &lt;&lt; 16 &amp; 0x80000000; //sign
  *i |= (exp-15+127) &lt;&lt; 23; //exponent 
  *i |= (Xi_Value &amp; 0x3FF) &lt;&lt; 13; //value
  return g;
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/komap.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/komap.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/komap.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/komap.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/komap.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/komap.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/komap.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/komap.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/komap.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/komap.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/komap.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/komap.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/komap.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/komap.wordpress.com/358/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=358&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://komap.wordpress.com/2011/12/01/convert-16-bit-half-float-to-32-bit-float/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ecaff5494edc21710159b5c7fd162143?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">komap</media:title>
		</media:content>
	</item>
		<item>
		<title>copy DB from MS SQL to MYSQL</title>
		<link>http://komap.wordpress.com/2011/07/21/copy-db-from-ms-sql-to-mysql/</link>
		<comments>http://komap.wordpress.com/2011/07/21/copy-db-from-ms-sql-to-mysql/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 15:33:02 +0000</pubDate>
		<dc:creator>komap</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bulk]]></category>
		<category><![CDATA[copy data]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[mysq]]></category>
		<category><![CDATA[odbc]]></category>

		<guid isPermaLink="false">http://komap.wordpress.com/?p=345</guid>
		<description><![CDATA[I&#8217;ve burned too much on this simple task, so I want to keep some gotchas it here. The task: copy DB from MS SQL to MYSQL. Tools MySQL migrate &#8212; I couldn&#8217;t make it work.   http://www.convert-in.com/ &#8212; seem to be OK, but demo version is limited, so I&#8217;m not sure. Full version &#8211; $50. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=345&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve burned too much on this simple task, so I want to keep some gotchas it here.<br />
The task: copy DB from MS SQL to MYSQL.</p>
<h2>Tools</h2>
<ul>
<li>MySQL migrate &#8212; I couldn&#8217;t make it work.</li>
<li>  http://www.convert-in.com/ &#8212; seem to be OK, but demo version is limited, so I&#8217;m not sure. Full version &#8211; $50.</li>
<li><a title="bcp" href="http://msdn.microsoft.com/en-us/library/ms162802.aspx">bcp</a> &#8211; command line tool; it was extremely difficult (yet possible) to export to a file that MySQL can eat.</li>
</ul>
<h2>Code</h2>
<p><pre class="brush: cpp;">

dbcDataAdapter l_SourceDA = new OdbcDataAdapter(l_QuerySource, m_strSource);
        OdbcDataAdapter l_TargetDA = new OdbcDataAdapter(l_QueryTarget, m_strTarget);
        OdbcCommandBuilder cmb = new OdbcCommandBuilder(l_TargetDA); //mandatory! Even if I don't use cmb, this line is crucial as in creates INSERT command
        string l_TableName = cmb.QuoteIdentifier(Xi_TableName, m_cTarget);

        DataSet l_SourceDS = new DataSet();
        DataSet l_TargetDS = new DataSet();
        int l_Rows = l_SourceDA.Fill(l_SourceDS, Xi_TableName);
        if (l_Rows &lt;= 0)
        {
          Log(&quot;Empty table&quot;);
          return;
        }
        l_TargetDA.Fill(l_TargetDS, l_TableName);

        DataTable l_tblSource = l_SourceDS.Tables[Xi_TableName];
        DataTable l_tblTarget = l_TargetDS.Tables[l_TableName];

        int l_Errors = 0;
        // Loop through the top five rows, and write the first column to the screen.
        foreach (DataRow l_r in l_tblSource.Rows)
        {
          try
          {
            l_tblTarget.ImportRow(l_r);
            l_tblTarget.Rows[l_tblTarget.Rows.Count - 1].SetAdded();
          }
          catch (OdbcException ex)
          {
            Log(ex.Message);
            l_Errors++;
          }
        }
        Log(string.Format(&quot;table {0}: {1} errors out of {2} records&quot;,
          Xi_TableName, l_Errors, l_Rows));
        DataSet l_Changed = l_TargetDS.GetChanges();
        tblTarget.Update(l_Changed);

</pre></p>
<p>This is OK; but I needed support for tables with dash (&#8220;-&#8221;).<br />
This was much harder; this thread was useful.<br />
So two changes that fix it:<br />
<pre class="brush: cpp;">
   //create command
    OdbcCommand cmdInsert = cmb.GetInsertCommand();
        cmdInsert.CommandText = cmdInsert.CommandText.ToLower().Replace(Xi_TableName.ToLower(), &quot;`&quot; + Xi_TableName + &quot;`&quot;); 
//MSSQL use &quot;[&quot; and &quot;]&quot;; there are prefix/postfix fields somehere in the data adapter
     ...

//instead of just updating target data set:
 OdbcDataAdapter l_NewTargetDA = new OdbcDataAdapter(l_TargetDA.SelectCommand);
        l_NewTargetDA.TableMappings.Add(&quot;Table&quot;, l_TableName);
        l_NewTargetDA.InsertCommand = cmdInsert;
        l_NewTargetDA.Update(l_Changed);
</pre></p>
<p>Hopefully this will be useful for someone.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/komap.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/komap.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/komap.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/komap.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/komap.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/komap.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/komap.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/komap.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/komap.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/komap.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/komap.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/komap.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/komap.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/komap.wordpress.com/345/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=345&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://komap.wordpress.com/2011/07/21/copy-db-from-ms-sql-to-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ecaff5494edc21710159b5c7fd162143?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">komap</media:title>
		</media:content>
	</item>
		<item>
		<title>One more HLSL trick</title>
		<link>http://komap.wordpress.com/2011/07/07/one-more-hlsl-trick/</link>
		<comments>http://komap.wordpress.com/2011/07/07/one-more-hlsl-trick/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 17:34:08 +0000</pubDate>
		<dc:creator>komap</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[HLSL]]></category>
		<category><![CDATA[optimizations]]></category>

		<guid isPermaLink="false">http://komap.wordpress.com/?p=337</guid>
		<description><![CDATA[One more trick to save several expensive instructions on HLSL shader model 2<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=337&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When implementing a quite complex pixel shader on pixel shader for multi-cascade <a href="http://en.wikipedia.org/wiki/Shadow_mapping">shadows maps</a> on shader model 2.0, I&#8217;d got a usual error message saying that &#8220;<em>Arithmetic instruction limit of 64 exceeded</em>&#8220;, so once again I have to find an instruction slot.</p>
<p>I had a code that tries to find the best shadow map for current pixel, something like:<br />
<pre class="brush: cpp;">
//float2 map[] is a u/v pair; if it is &quot;inside&quot; the texture, I can use it
if (map[0].x &lt; 0 || map[0].x &gt; 1 || 
    map[0].y &lt; 0 || map[0].y &gt; 1)
{
  //...
}
</pre><br />
This code was converted to:<br />
<pre class="brush: cpp;">
//float2 map[] is a u/v pair; if it is &quot;inside&quot; the texture, I can use it
if( any (map[0]-saturate(map[0] ) ) )
{
  //...
}
</pre><br />
This takes much less instructions, so now I have some free slots!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/komap.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/komap.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/komap.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/komap.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/komap.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/komap.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/komap.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/komap.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/komap.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/komap.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/komap.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/komap.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/komap.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/komap.wordpress.com/337/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=337&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://komap.wordpress.com/2011/07/07/one-more-hlsl-trick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ecaff5494edc21710159b5c7fd162143?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">komap</media:title>
		</media:content>
	</item>
		<item>
		<title>-1.#IND000000000000</title>
		<link>http://komap.wordpress.com/2011/05/11/1-ind000000000000/</link>
		<comments>http://komap.wordpress.com/2011/05/11/1-ind000000000000/#comments</comments>
		<pubDate>Wed, 11 May 2011 09:35:18 +0000</pubDate>
		<dc:creator>komap</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[-1.#IND000000000000]]></category>
		<category><![CDATA[breakpoint]]></category>
		<category><![CDATA[NoN]]></category>

		<guid isPermaLink="false">http://komap.wordpress.com/?p=326</guid>
		<description><![CDATA[vairable != vairable<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=326&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Q: In Visual Studio, how to set conditional breakpoint on  <a href="http://en.wikipedia.org/wiki/NaN#Display" title="NaN">-1.#IND000000000000</a> ?<br />
<pre class="brush: cpp;"> vairable == -1.#IND000000000000//this cannot work, of course
</pre><br />
A:<br />
<pre class="brush: cpp;">
vairable != vairable
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/komap.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/komap.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/komap.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/komap.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/komap.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/komap.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/komap.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/komap.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/komap.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/komap.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/komap.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/komap.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/komap.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/komap.wordpress.com/326/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=326&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://komap.wordpress.com/2011/05/11/1-ind000000000000/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ecaff5494edc21710159b5c7fd162143?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">komap</media:title>
		</media:content>
	</item>
		<item>
		<title>More productive programming</title>
		<link>http://komap.wordpress.com/2011/04/20/more-productive-programming/</link>
		<comments>http://komap.wordpress.com/2011/04/20/more-productive-programming/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 09:00:17 +0000</pubDate>
		<dc:creator>komap</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://komap.wordpress.com/?p=314</guid>
		<description><![CDATA[5 tips for more productive environment<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=314&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>(inspired by <a href="http://www.dextronet.com/blog/2011/04/10-best-tricks-of-fooling-myself-to-work/"> 10 best tricks of fooling myself to work </a> and <a href="http://www.dextronet.com/blog/2010/10/create-more-productive-environment-at-your-computer-desk-10-tips/">Create more productive environment at your desk</a>)</p>
<ol>
<li><strong>Drink a good tea constantly.</strong><br />
it helps to concentrate. I recommend <a href="http://en.wikipedia.org/wiki/Pu-erh_tea">Pu-erh </a>or <a href="http://en.wikipedia.org/wiki/Oolong">Oolong</a>)</li>
<li><strong>Drink a your tea with no sugar.</strong><br />
not only it tastes much better (this is the only reasonable way to drink a tea), but also when it is accidentally  spilled on a keyboard, the keyboard is recoverable, and the keys do not stick. Thus you will be significantly more productive than somebody who drinks tea/coffee  with sugar (or Pepsi or whatever)</li>
<li><strong>Keep your browser closed; get updates using RSS readers.</strong><br />
I personally had been spending  a lot of time  checking <a href="http://www.walla.co.il/">news sites</a>/ <a href="http://slashdot.org/">/.</a> / <a href="http://news.ycombinator.com/">HN</a> <a href="http://www.merriam-webster.com/word-of-the-day/">/Merriam-Webster&#8217;s Word of the Day</a>/<a href="German Word of the Day - Free German Vocabulary Lessons Online">German word of the day</a>/ <a href="en.wikipedia.org/">Wik</a><a href="ru.wikipedia.org/">ipe</a><a href="http://he.wikipedia.org/">dia</a> watch list  etc.  each time &#8220;the code is compiling&#8221;, and then continue to surf. Now RSS saves me a lot of time.</li>
<li><strong>Ask a co-worker for help, if you are stuck on a problem more than 30 minutes.</strong><br />
usually, you will find the solution even before you finish explaining him the issue. If not, you give him a chance to solve your problem and fill genius.</li>
<li><strong>Use <a href="http://en.wikipedia.org/wiki/Ginkgo_biloba">Ginkgo biloba</a>, if you still feel dumb.</strong><br />
I don&#8217;t know whether it&#8217; effect is fully <a href="http://en.wikipedia.org/wiki/Psychosomatic">Psychosomatic</a> or not, but it helps.</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/komap.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/komap.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/komap.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/komap.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/komap.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/komap.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/komap.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/komap.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/komap.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/komap.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/komap.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/komap.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/komap.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/komap.wordpress.com/314/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=314&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://komap.wordpress.com/2011/04/20/more-productive-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ecaff5494edc21710159b5c7fd162143?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">komap</media:title>
		</media:content>
	</item>
		<item>
		<title>HLSL trick #2</title>
		<link>http://komap.wordpress.com/2011/04/14/hlsl-trick-2/</link>
		<comments>http://komap.wordpress.com/2011/04/14/hlsl-trick-2/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 14:55:39 +0000</pubDate>
		<dc:creator>komap</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[dotproduct]]></category>
		<category><![CDATA[HLSL]]></category>
		<category><![CDATA[inctructions]]></category>
		<category><![CDATA[optimizations]]></category>
		<category><![CDATA[shader]]></category>
		<category><![CDATA[trick]]></category>

		<guid isPermaLink="false">http://komap.wordpress.com/?p=302</guid>
		<description><![CDATA[Saving some expensive instruction in shader model 2&#8230; (Trick #1 is described here) Instead of, e. g., try The trick is that sometimes if you want to sum some floats (or vectors), it may be cheaper to use dot product with vector (1, &#8230; , 1)<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=302&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Saving some expensive instruction in shader model 2&#8230;<br />
(Trick #1 is described <a href="http://komap.wordpress.com/2011/03/02/hlsl-trick/">here</a>)</p>
<p>Instead of, e. g.,<br />
<pre class="brush: cpp;">
float getTotalDiffuse()
{
 float l1 = getDiffuse(g_light1);
 float l2 = getDiffuse(g_light2);
 float l3 = getDiffuse(g_light3);
 float l4 = getDiffuse(g_light4);
 return l1+l2+l3+l4;
}
</pre></p>
<p>try<br />
<pre class="brush: cpp;">
float getTotalDiffuse()
{
 float4 l = {getDiffuse(g_light1),
              getDiffuse(g_light2),
              getDiffuse(g_light3),
              getDiffuse(g_light4)};
 return dot (l, float4(1,1,1,1));
}
</pre><br />
The trick is that sometimes if you want to sum some floats (or vectors), it may be cheaper to use dot product with vector (1, &#8230; , 1)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/komap.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/komap.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/komap.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/komap.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/komap.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/komap.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/komap.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/komap.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/komap.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/komap.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/komap.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/komap.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/komap.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/komap.wordpress.com/302/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=302&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://komap.wordpress.com/2011/04/14/hlsl-trick-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ecaff5494edc21710159b5c7fd162143?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">komap</media:title>
		</media:content>
	</item>
		<item>
		<title>HLSL trick</title>
		<link>http://komap.wordpress.com/2011/03/02/hlsl-trick/</link>
		<comments>http://komap.wordpress.com/2011/03/02/hlsl-trick/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 16:44:54 +0000</pubDate>
		<dc:creator>komap</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[HLSL]]></category>
		<category><![CDATA[optimizations]]></category>
		<category><![CDATA[PixelShader]]></category>
		<category><![CDATA[shaders]]></category>

		<guid isPermaLink="false">http://komap.wordpress.com/?p=283</guid>
		<description><![CDATA[If you write a HLSL Shader Model 2 you know you are limited to 32 const registers. Here is a trick that helped me to save one. Suppose you want to write in pixel shader: But you cannot write in ShaderModel 2 &#8220;array[index] = blah&#8220;. Second try: Of course, there is no switch/case in ShaderModel [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=283&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you write a <a href="http://en.wikipedia.org/wiki/High_Level_Shader_Language">HLSL</a> Shader Model 2 you know you are limited to 32 const registers. Here is a trick that helped me to save one.</p>
<p>Suppose you want to write in pixel shader:<br />
<pre class="brush: cpp;">
 float4x4 l_Color=
   {
      tex2D(samTex0, In.Tex0),
      tex2D(samTex1, In.Tex1),
      tex2D(samTex2, In.Tex2),
      tex2D(samTex3, In.Tex3)
   };
 ...
   l_Color[g_BlendLayer] = foo(l_Color[g_BlendLayer]); 
   //OOPS! illegal syntax
   out.Color = combine (Color);
</pre><br />
But you cannot write in ShaderModel 2 &#8220;<em>array[index] = blah</em>&#8220;.</p>
<p>Second try:<br />
<pre class="brush: cpp;">
   ...
  float4 blended = foo(l_Color[g_BlendLayer]);
   switch (BlendLayer)
   {
      case 0: l_Color[0] = blended; break;
      case 1: l_Color[1] = blended; break;
      case 2: l_Color[2] = blended; break;
      case 3: l_Color[3] = blended; break;
   }
   //OOPS! illegal syntax
   ...
</pre><br />
Of course, there is no switch/case in ShaderModel 2&#8230;</p>
<p><pre class="brush: cpp;">
   ...
  float4 blended = foo(l_Color[g_BlendLayer]);
   switch (BlendLayer)
   {
      case 0: l_Color[0] = blended; break;
      case 1: l_Color[1] = blended; break;
      case 2: l_Color[2] = blended; break;
      case 3: l_Color[3] = blended; break;
   }
   //OOPS! illegal syntax
   ...
</pre><br />
Same problem: &#8220;<em>array[index] = blah</em>&#8220;.<br />
<pre class="brush: cpp;">
   ...
  float4 blended = foo(l_Color[g_BlendLayer]);
  if (0 == BlendLayer) l_Color[0] = blended; else
  if (1 == BlendLayer) l_Color[1] = blended; else
  if (2 == BlendLayer) l_Color[2] = blended; else
  if (3 == BlendLayer) l_Color[3] = blended; 
   //OOPS! Too bad
   ...
</pre><br />
Although this code is syntactically correct, it is wrong: condition are bad, and nested ifs are even worse (just look on disassembly). Too much instructions.</p>
<p><pre class="brush: cpp;">
   ...
  float4 blended = foo(l_Color[g_BlendLayer]);
  if (0 == BlendLayer) l_Color[0] = blended; 
  if (1 == BlendLayer) l_Color[1] = blended; 
  if (2 == BlendLayer) l_Color[2] = blended; 
  if (3 == BlendLayer) l_Color[3] = blended; 
   //Much better!
   ...
</pre><br />
This code (same as previous, but without &#8220;else&#8221;s, is much better. But still, I get <strong>&#8220;error X5589: Invalid const register num: 32. Max allowed is 31.&#8221;</strong></p>
<p><pre class="brush: cpp;">
   ...
  float4 blended = foo(l_Color[g_BlendLayer]);
  if (0 == BlendLayer--) l_Color[0] = blended; 
  if (0 == BlendLayer--) l_Color[1] = blended; 
  if (0 == BlendLayer--) l_Color[2] = blended; 
  if (0 == BlendLayer--) l_Color[3] = blended; 
   //It works!
   ...
</pre></p>
<p>Learning the assembly code really helps.<br />
Here is how you get .asm files from your HLSL shaders,<br />
using Microsoft&#8217;s <a href="http://msdn.microsoft.com/en-us/library/bb509710(v=vs.85).aspx#Legacy">fxc</a> tool:<br />
<pre class="brush: bash;">
fxc /Gfp /Zi /T ps_2_0 /Fc out.asm l:\efx\mini.fx /E PS_Test
</pre><br />
or, to get nice HTML:<br />
<pre class="brush: plain;">
fxc /Gfp /Zi /T ps_2_0 /Cc /Fc out.asm.html l:\efx\mini.fx /E PS_Test
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/komap.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/komap.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/komap.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/komap.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/komap.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/komap.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/komap.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/komap.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/komap.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/komap.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/komap.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/komap.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/komap.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/komap.wordpress.com/283/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=283&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://komap.wordpress.com/2011/03/02/hlsl-trick/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ecaff5494edc21710159b5c7fd162143?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">komap</media:title>
		</media:content>
	</item>
		<item>
		<title>words&#8230;.</title>
		<link>http://komap.wordpress.com/2011/02/21/words/</link>
		<comments>http://komap.wordpress.com/2011/02/21/words/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 13:06:20 +0000</pubDate>
		<dc:creator>komap</dc:creator>
				<category><![CDATA[Linguistics]]></category>
		<category><![CDATA[antonym]]></category>
		<category><![CDATA[autological]]></category>
		<category><![CDATA[awkward]]></category>
		<category><![CDATA[Doublet]]></category>
		<category><![CDATA[Etymology]]></category>
		<category><![CDATA[FLAB]]></category>
		<category><![CDATA[heterological]]></category>
		<category><![CDATA[linguistics]]></category>
		<category><![CDATA[onomatopea]]></category>
		<category><![CDATA[Portmanteau]]></category>
		<category><![CDATA[Pronunciation]]></category>
		<category><![CDATA[RAS]]></category>
		<category><![CDATA[synonym]]></category>
		<category><![CDATA[TLA]]></category>
		<category><![CDATA[words]]></category>

		<guid isPermaLink="false">http://komap.wordpress.com/?p=272</guid>
		<description><![CDATA[unordered facts. Etymology of etymology: Greek ἐτυμολογία (etumologíā); from ἔτυμον (étumon), meaning &#8220;true sense&#8221;, and -λογία (-logía), meaning &#8220;study&#8221;; from λόγος (lógos), meaning &#8220;speech, account, reason.&#8221; (wikipedia) Pronunciation of pronunciation is IPA: /pɹəˌnʌnsiˈeɪʃən/, SAMPA: /pr@%nVnsi&#8221;eIS@n/ (wiktionary) Doublet for doublet is twin. The term antonym is synonymous with opposite. Antonym to antonym is synonym. There is no [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=272&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>unordered facts.</p>
<p><strong>Etymology of etymology</strong>:  Greek ἐτυμολογία (etumologíā); from ἔτυμον (étumon), meaning &#8220;true sense&#8221;, and -λογία (-logía), meaning &#8220;study&#8221;; from λόγος (lógos), meaning &#8220;speech, account, reason.&#8221; (<a title="wikipedia" href="http://en.wikipedia.org/wiki/tymology#Etymology_of_.22etymology.22">wikipedia</a>)</p>
<p><strong>Pronunciation of pronunciation</strong> is IPA: /pɹəˌnʌnsiˈeɪʃən/, SAMPA: /pr@%nVnsi&#8221;eIS@n/ (<a title="wiktionary" href="http://en.wiktionary.org/wiki/pronunciation">wiktionary</a>)</p>
<p><strong><a href="http://en.wikipedia.org/wiki/Doublet_(linguistics)">Doublet </a>for doublet<a href="http://en.wikipedia.org/wiki/Doublet_(linguistics)"></a></strong> is twin.</p>
<p>The term <strong><a href="http://en.wikipedia.org/wiki/Antonym">antonym</a> </strong>is synonymous with <strong>opposite</strong>.</p>
<p><strong>Antonym to antonym</strong> is synonym.</p>
<p>There is no<strong> synonym to synonym</strong>, AFAIK.</p>
<p><strong> TLA is TLA.</strong> (<a href="http://en.wikipedia.org/wiki/Three-letter_acronym">Three-letter acronym</a>)</p>
<p><strong>FLAB is FLAB</strong> (<a title="Four-letter abbreviation" href="http://en.wikipedia.org/wiki/Four-letter_abbreviation">Four-letter abbreviation</a>)</p>
<p><strong><a title="Onomatopeic" href="http://en.wikipedia.org/wiki/Onomatopeic">Onomatopoeic</a> is not onomatopeic</strong>.</p>
<p><strong><a href="http://en.wiktionary.org/wiki/awkward">Awkward</a> is an awkward word</strong>.</p>
<p><strong><a href="http://en.wikipedia.org/wiki/RAS_syndrome">RAS syndrome </a>is an example of RAS syndrome.</strong></p>
<p><strong><a href="http://en.wikipedia.org/wiki/Portmanteau">Portmanteau</a> is Portmanteau.</strong></p>
<p>hm.</p>
<p><a href="http://en.wikipedia.org/wiki/Grelling-Nelson_paradox">heterological is not heterological nor autological.</a></p>
<p><strong><br />
</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/komap.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/komap.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/komap.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/komap.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/komap.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/komap.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/komap.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/komap.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/komap.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/komap.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/komap.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/komap.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/komap.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/komap.wordpress.com/272/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=272&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://komap.wordpress.com/2011/02/21/words/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ecaff5494edc21710159b5c7fd162143?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">komap</media:title>
		</media:content>
	</item>
		<item>
		<title>Puzzle</title>
		<link>http://komap.wordpress.com/2010/08/24/puzzle/</link>
		<comments>http://komap.wordpress.com/2010/08/24/puzzle/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 18:47:46 +0000</pubDate>
		<dc:creator>komap</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[puzzle]]></category>

		<guid isPermaLink="false">http://komap.wordpress.com/?p=261</guid>
		<description><![CDATA[playing with JavaScript: 10-matchsticks puzzle<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=261&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>playing with JavaScript:<br />
<a href="http://komap.110mb.com/match.html">10-matchsticks puzzle</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/komap.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/komap.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/komap.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/komap.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/komap.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/komap.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/komap.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/komap.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/komap.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/komap.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/komap.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/komap.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/komap.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/komap.wordpress.com/261/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=261&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://komap.wordpress.com/2010/08/24/puzzle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ecaff5494edc21710159b5c7fd162143?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">komap</media:title>
		</media:content>
	</item>
		<item>
		<title>999&#8230;</title>
		<link>http://komap.wordpress.com/2010/02/08/999/</link>
		<comments>http://komap.wordpress.com/2010/02/08/999/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 20:43:07 +0000</pubDate>
		<dc:creator>komap</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[999...]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[sequence]]></category>

		<guid isPermaLink="false">http://komap.wordpress.com/?p=252</guid>
		<description><![CDATA[Question Let N = any number not divisible by 2 and 5. Does there exist a k (for each such N), such that 10^k &#8211; 1 is divisible by N? Or: Is there 99..9 for any N, such as 99..9 is divisible by N, if N is coprime with 10? Answer Yes.  It is multiplicative [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=252&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Question</h2>
<p>Let N = any number not divisible by 2 and 5.<br />
Does there exist a k (for each such N), such that 10^k &#8211; 1 is divisible by N?<br />
Or: Is there 99..9 for any N, such as 99..9 is divisible by N, if N is coprime with 10?</p>
<h2>Answer</h2>
<p>Yes.  It is multiplicative order of 10 modulo N. The sequence is can be found at <a href="http://www.research.att.com/~njas/sequences/A053453">The On-Line Encyclopedia of Integer Sequences</a>.</p>
<h2>Proof</h2>
<p>Trivial.</p>
<h2>Code</h2>
<p><code></p>
<p>-- all numbers than cannot be devided by 2 or 5<br />
seq1 :: [Integer]<br />
seq1 = filter (\a-&gt;(a `mod` 10) `elem` [1,3,7,9]) [1..]</p>
<p>-- find 99..9 that can be devided by n<br />
findNum::Integer-&gt;Integer<br />
findNum n = head $ [x | x&lt;-[1..], (10^x-1) `mod` n == 0]</p>
<p> --prints the sequene<br />
take 100 $ map findNum3 seq2</p>
<p></code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/komap.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/komap.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/komap.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/komap.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/komap.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/komap.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/komap.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/komap.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/komap.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/komap.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/komap.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/komap.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/komap.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/komap.wordpress.com/252/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=komap.wordpress.com&amp;blog=6851517&amp;post=252&amp;subd=komap&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://komap.wordpress.com/2010/02/08/999/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ecaff5494edc21710159b5c7fd162143?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">komap</media:title>
		</media:content>
	</item>
	</channel>
</rss>
