<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>blog of ducklink.com</title>
	
	<link>http://libg.org</link>
	<description />
	<lastBuildDate>Tue, 18 Jan 2011 04:54:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/libg" /><feedburner:info uri="libg" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>libg</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Blog Relaunched</title>
		<link>http://feedproxy.google.com/~r/libg/~3/Zuu3qAnir08/</link>
		<comments>http://libg.org/2011/01/17/blog-relaunched/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 14:53:16 +0000</pubDate>
		<dc:creator>Mason</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://libg.org/?p=84</guid>
		<description><![CDATA[After 2 years of hibernating, the blog is relaunched on ducklink.com. You may find more interesting posts http://www.ducklink.com/blog. Read more about relaunch. Thanks!]]></description>
			<content:encoded><![CDATA[<p>After 2 years of hibernating, the blog is relaunched on ducklink.com. You may find more interesting posts <a href="http://www.ducklink.com/blog">http://www.ducklink.com/blog</a>. Read <a href="http://www.ducklink.com/blog/2011/blog-relaunched/">more about relaunch</a>. Thanks!</p>
<img src="http://feeds.feedburner.com/~r/libg/~4/Zuu3qAnir08" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://libg.org/2011/01/17/blog-relaunched/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://libg.org/2011/01/17/blog-relaunched/</feedburner:origLink></item>
		<item>
		<title>How to Fix the Start Error for Windows Search Service to Enable the Index in Vista</title>
		<link>http://feedproxy.google.com/~r/libg/~3/CIFFyi-Wi6s/</link>
		<comments>http://libg.org/2009/03/23/how-to-fix-the-start-error-for-windows-search-service-to-enable-the-index-in-vista/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 03:03:42 +0000</pubDate>
		<dc:creator>Mason</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://libg.org/2009/03/23/how-to-fix-the-start-error-for-windows-search-service-to-enable-the-index-in-vista/</guid>
		<description><![CDATA[I’m not sure why my windows search service broken recently. I saw an error when I attempted to start the service “Windows Search” in administrative tools –&#62; services console. Windows could not start the Windows Search on Local Computer.  For more information, review the System Event Log.  If this is a non-Microsoft service, contact the [...]]]></description>
			<content:encoded><![CDATA[<p>I’m not sure why my windows search service broken recently. I saw an error when I attempted to start the service “Windows Search” in administrative tools –&gt; services console.</p>
<blockquote><p>Windows could not start the Windows Search on Local Computer.  For more information, review the System Event Log.  If this is a non-Microsoft service, contact the service vendor, and refer to service-specific error code &#8211; 2147218141.</p></blockquote>
<p>I went to event viewer, I saw some warnings as:</p>
<blockquote><p>Event ID 1008: The Windows Search Service is attempting to remove the old catalog.</p>
<p>Event ID 1010: The Windows Search Service has successfully removed the old catalog.</p>
<p>Event ID 1013: Windows Search Service stopped normally.</p></blockquote>
<p>I searched on internet via google, and a lot of reports on this error, the solution in <a href="http://www.vistax64.com/">Windows Vista Forums</a> may resolve some people’s issue, but doesn’t work for me.</p>
<p>Eventually my solution is simple and easy:</p>
<p><span style="color: #000080;">1. Select Windows Search 4.0 from your installed updates. You may open your control panel and search for the panels as pictures below. I like this feature in Vista.</span></p>
<p><span style="color: #000080;">2. Uninstall the Windows Search 4.0 and restart. Open “Indexing Options”, you may find the windows search is back <img src='http://libg.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </span></p>
<p><span style="color: #000080;">3. If you want to re-install the Windows Search, </span><a href="http://download.microsoft.com/download/3/7/F/37F0E553-3623-4DC8-90DD-1C4AC3F6E158/Windows6.0-KB940157-x86.msu"><span style="color: #000080;">Download Windows Search 4.0 here!</span></a></p>
<p><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="Capture 2009-03-23 10.49.42" src="http://libg.org/wp-content/uploads/2009/03/capture20090323104942.png" border="0" alt="Capture 2009-03-23 10.49.42" width="739" height="600" /></p>
<p><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="Capture 2009-03-23 10.53.21" src="http://libg.org/wp-content/uploads/2009/03/capture20090323105321.png" border="0" alt="Capture 2009-03-23 10.53.21" width="667" height="540" /></p>
<p>Good luck!</p>
<img src="http://feeds.feedburner.com/~r/libg/~4/CIFFyi-Wi6s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://libg.org/2009/03/23/how-to-fix-the-start-error-for-windows-search-service-to-enable-the-index-in-vista/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://libg.org/2009/03/23/how-to-fix-the-start-error-for-windows-search-service-to-enable-the-index-in-vista/</feedburner:origLink></item>
		<item>
		<title>Every time Vista Installer popuped for “Windows configures Microsoft Office professional 2007”</title>
		<link>http://feedproxy.google.com/~r/libg/~3/O2GIyzGKLQo/</link>
		<comments>http://libg.org/2009/03/16/every-time-vista-installer-popuped-for-windows-configures-microsoft-office-professional-2007/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 02:32:57 +0000</pubDate>
		<dc:creator>Mason</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Office]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://libg.org/2009/03/16/every-time-vista-installer-popuped-for-windows-configures-microsoft-office-professional-2007/</guid>
		<description><![CDATA[I installed office 2007 on Vista and it works well for several month. Yesterday I installed Visio 2003 from Visual Studio 2005 Team System. Every time when I opened Visio, it popuped a dialog to configure Microsoft Office, and then a registry key access error, and then rollback the configure progress. Then I try to [...]]]></description>
			<content:encoded><![CDATA[<p>I installed office 2007 on Vista and it works well for several month. Yesterday I installed Visio 2003 from Visual Studio 2005 Team System. Every time when I opened Visio, it popuped a dialog to configure Microsoft Office, and then a registry key access error, and then rollback the configure progress. Then I try to uninstall Visio, same registry key access error. At last I tried various ways and successfully uninstalled Visio. But when I open I open an office product (Word/Excel/PowerPoint, and etc), it gives me a message “please wait while Windows configures Microsoft Office professional Plus 2007”. Then it pops a window with a status bar for “Configuration Progress”. After several minutes, the office product opened. So I uninstalled office entirely, booted, and reinstalled again and again. My account is a domain user and is belong to administrators user group on my machine. I looked this up online, tried different approaches and finally found this one:</p>
<p>Either way you would have to use SubInAcl. <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e8ba3e56-d8fe-4a91-93cf-ed6985e3927b&amp;displaylang=en">Download it </a>from microsoft.com     <br />This tool allows us to edit registry entries even those which you need special rights for.     <br />We will make simple files, depending on the application you need to fix, with code that will fix your registry entries.     <br />1. Download and install SubinAcl.     <br />2. Locate the install folder (default is Program Files/Windows Resource Kits/Tools/)     <br />3. Open Notepad     <br />4. Add the lines you need for your applications (<em>you can find the lines bellow</em>)     <br />5. Save the file as &quot;Officefix.cmd&quot; in the folder where you found SubinAcl.     <br />6. Open the officefix.cmd</p>
<p>I didn’t found the lines of code that “you can find the lines bellow”. Here is the script I used and it works:</p>
<p>subinacl /subkeyreg HKEY_LOCAL_MACHINE /grant=administrators=f /grant=system=f    <br />subinacl /subkeyreg HKEY_CURRENT_USER /grant=administrators=f /grant=system=f     <br />subinacl /subkeyreg HKEY_CLASSES_ROOT /grant=administrators=f /grant=system=f     <br />subinacl /subdirectories %SystemDrive% /grant=administrators=f /grant=system=f     <br />subinacl /subdirectories %windir%*.* /grant=administrators=f /grant=system=f     <br />secedit /configure /cfg %windir%infdefltbase.inf /db defltbase.sdb /verbose</p>
<img src="http://feeds.feedburner.com/~r/libg/~4/O2GIyzGKLQo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://libg.org/2009/03/16/every-time-vista-installer-popuped-for-windows-configures-microsoft-office-professional-2007/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		<feedburner:origLink>http://libg.org/2009/03/16/every-time-vista-installer-popuped-for-windows-configures-microsoft-office-professional-2007/</feedburner:origLink></item>
		<item>
		<title>Do’s on writing software design and architecture documents</title>
		<link>http://feedproxy.google.com/~r/libg/~3/uKj44QjryZo/</link>
		<comments>http://libg.org/2008/10/09/dos-on-writing-software-design-and-architecture-documents/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 05:20:58 +0000</pubDate>
		<dc:creator>Mason</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Software Architecture]]></category>

		<guid isPermaLink="false">http://libg.org/2008/10/09/dos-on-writing-software-design-and-architecture-documents/</guid>
		<description><![CDATA[&#160; · If you drone endlessly with details, you don&#8217;t see the forest from the trees. · If you don&#8217;t use multiple views, you are likely to miss important aspects of the solution · If you aren&#8217;t focused on quality attributes, then you are most likely documenting design and not architecture · And if you [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<blockquote><p>· If you drone endlessly with details, you don&#8217;t see the forest from the trees. </p>
<p>· If you don&#8217;t use multiple views, you are likely to miss important aspects of the solution </p>
<p>· If you aren&#8217;t focused on quality attributes, then you are most likely documenting design and not architecture </p>
<p>· And if you don&#8217;t explain the rationale,&#160; then the document doesn&#8217;t have a lot of added value beyond the code itself</p>
</blockquote>
<img src="http://feeds.feedburner.com/~r/libg/~4/uKj44QjryZo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://libg.org/2008/10/09/dos-on-writing-software-design-and-architecture-documents/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://libg.org/2008/10/09/dos-on-writing-software-design-and-architecture-documents/</feedburner:origLink></item>
		<item>
		<title>Fix gap between list items IE / Win in CSS</title>
		<link>http://feedproxy.google.com/~r/libg/~3/DPEwOJgjoHg/</link>
		<comments>http://libg.org/2008/10/03/fix-gap-between-list-items-ie-win-in-css/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 06:14:12 +0000</pubDate>
		<dc:creator>Mason</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://libg.org/2008/10/03/fix-gap-between-list-items-ie-win-in-css/</guid>
		<description><![CDATA[I got the same issue and pained me for a long time, here is the solution: http://phonophunk.com/articles/ie-fix-for-gaps-between-list-items.php. using &#34;vertical-align: bottom&#34; in &#34;ul li&#34;, Perfect!]]></description>
			<content:encoded><![CDATA[<p>I got the same issue and pained me for a long time, here is the solution: <a title="http://phonophunk.com/articles/ie-fix-for-gaps-between-list-items.php" href="http://phonophunk.com/articles/ie-fix-for-gaps-between-list-items.php">http://phonophunk.com/articles/ie-fix-for-gaps-between-list-items.php</a>. using &quot;vertical-align: bottom&quot; in &quot;ul li&quot;, Perfect! </p>
<img src="http://feeds.feedburner.com/~r/libg/~4/DPEwOJgjoHg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://libg.org/2008/10/03/fix-gap-between-list-items-ie-win-in-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://libg.org/2008/10/03/fix-gap-between-list-items-ie-win-in-css/</feedburner:origLink></item>
		<item>
		<title>Floating-point: Bit Value of INF, NAN, DEN</title>
		<link>http://feedproxy.google.com/~r/libg/~3/QMkqk-WPw-0/</link>
		<comments>http://libg.org/2008/09/26/floating-point-bit-value-of-inf-nan-den/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 04:55:22 +0000</pubDate>
		<dc:creator>Mason</dc:creator>
				<category><![CDATA[General C++]]></category>
		<category><![CDATA[Numeral]]></category>
		<category><![CDATA[floating point]]></category>

		<guid isPermaLink="false">http://libg.org/2008/09/26/floating-point-bit-value-of-inf-nan-den/</guid>
		<description><![CDATA[I have every write a post and mentioned a little bit about the binary format of IEEE 754 in Comparison of Float and Double Precision. In this post I made a table to indicate the details of bit values for the IEEE 754 32bit single-precision float, the bit values of some special floating point value, [...]]]></description>
			<content:encoded><![CDATA[<p>I have every write a post and mentioned a little bit about the binary format of <a href="http://en.wikipedia.org/wiki/IEEE_754" target="_blank">IEEE 754</a> in <a href="http://libg.org/2008/09/07/comparison-of-float-and-double-precision/" target="_blank">Comparison of Float and Double Precision</a>. In this post I made a table to indicate the details of bit values for the IEEE 754 32bit single-precision float, the bit values of some special floating point value, including Zero, One, Minus One, Smallest <a href="http://en.wikipedia.org/wiki/Denormal_number" target="_blank">denormalized number</a>, &#8220;Middle&#8221; denormalized number, Largest denormalized number, Smallest normalized number, Largest normalized number, Positive infinity, Negative infinity, Not a number (NaN).</p>
<p><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" src="http://libg.org/wp-content/uploads/2008/09/capture-2008-09-26-131257.png" border="0" alt="Capture 2008-09-26 13.12.57" width="1025" height="596" /></p>
<p>In the column &#8220;Watch in Windows&#8221;, I put what I can see from the watch window in Visual Studio 2008 (Visual C++ Environment).</p>
<img src="http://feeds.feedburner.com/~r/libg/~4/QMkqk-WPw-0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://libg.org/2008/09/26/floating-point-bit-value-of-inf-nan-den/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://libg.org/2008/09/26/floating-point-bit-value-of-inf-nan-den/</feedburner:origLink></item>
		<item>
		<title>Show Formatted Source Code with Syntax Highlight</title>
		<link>http://feedproxy.google.com/~r/libg/~3/zHra3qbUJ-M/</link>
		<comments>http://libg.org/2008/09/14/show-formatted-source-code-with-syntax-highlight/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 07:56:18 +0000</pubDate>
		<dc:creator>Mason</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[highlight]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://libg.org/2008/09/14/show-formatted-source-code-with-syntax-highlight/</guid>
		<description><![CDATA[LibG Code Viewer is a free web tool to view source code with syntax highlight. After I finished my post How to format source code in your blog, I decided to make a small tool for anyone who post source code file on Internet. I called this tool &#8220;LibG Code Viewer&#8220;, it used the method [...]]]></description>
			<content:encoded><![CDATA[<p><strong>LibG Code Viewer</strong> is a free web tool to view source code with syntax highlight.</p>
<p>After I finished my post <a title="Permanent Link to How to format source code in your blog" href="http://libg.org/2008/09/11/how-to-format-source-code-in-your-blog/">How to format source code in your blog</a>, I decided to make a small tool for anyone who post source code file on Internet. I called this tool &#8220;<strong><a href="http://libg.org/code.php" target="_blank">LibG Code Viewer</a></strong>&#8220;, it used the method I described in my previous blog. Here is the usage of this tool:</p>
<table border="1" cellspacing="0" cellpadding="2" width="535">
<tbody>
<tr>
<td width="533" valign="top"><span style="color: #000080;">http://libg.org/code.php?lang=<em>your source language</em>&amp;url=<em>link to your source code</em></span></td>
</tr>
</tbody>
</table>
<p>Below is the list of supported language and sample:</p>
<table border="1" cellspacing="0" cellpadding="2" width="535">
<tbody>
<tr>
<td width="80" valign="top"><strong>Language</strong></td>
<td width="86" valign="top"><strong>Parameter</strong></td>
<td width="367" valign="top"><strong>Sample</strong></td>
</tr>
<tr>
<td width="85" valign="top"><strong>C++</strong></td>
<td width="90" valign="top">cpp</td>
<td width="367" valign="top"><a title="http://libg.org/code.php?lang=cpp&amp;url=http://libg.googlecode.com/svn/trunk/inc/gifloat.h" href="http://libg.org/code.php?lang=cpp&amp;url=http://libg.org/code/sample.cpp">http://libg.org/code.php?lang=<span style="color: #000080;">cpp</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.cpp</span></a></td>
</tr>
<tr>
<td width="88" valign="top"><strong>C#</strong></td>
<td width="93" valign="top">csharp</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=csharp&amp;url=http://libg.org/code/sample.cs " target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">csharp</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.cs</span></a></span></td>
</tr>
<tr>
<td width="91" valign="top"><strong>CSS</strong></td>
<td width="95" valign="top">css</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=css&amp;url=http://libg.org/code/sample.css" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">css</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.css</span></a></span></td>
</tr>
<tr>
<td width="93" valign="top"><strong>Delphi</strong></td>
<td width="96" valign="top">delphi</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=delphi&amp;url=http://libg.org/code/sample.pas" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">delphi</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.pas</span></a></span></td>
</tr>
<tr>
<td width="94" valign="top"><strong>Java</strong></td>
<td width="97" valign="top">java</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=java&amp;url=http://libg.org/code/sample.java" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">java</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.java</span></a></span></td>
</tr>
<tr>
<td width="95" valign="top"><strong>Java Script</strong></td>
<td width="97" valign="top">js</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=js&amp;url=http://libg.org/code/sample.js" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">js</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.js</span></a></span></td>
</tr>
<tr>
<td width="96" valign="top"><strong>PHP</strong></td>
<td width="97" valign="top">php</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=php&amp;url=http://libg.org/code/sample.phpcode">http://libg.org/code.php?lang=<span style="color: #000080;">php</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.phpcode</span></a></span></td>
</tr>
<tr>
<td width="97" valign="top"><strong>Python</strong></td>
<td width="97" valign="top">py</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=py&amp;url=http://libg.org/code/sample.py" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">py</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.py</span></a></span></td>
</tr>
<tr>
<td width="97" valign="top"><strong>Ruby</strong></td>
<td width="97" valign="top">ruby</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=ruby&amp;url=http://libg.org/code/sample.rb" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">ruby</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.rb</span></a></span></td>
</tr>
<tr>
<td width="97" valign="top"><strong>Sql</strong></td>
<td width="97" valign="top">sql</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=sql&amp;url=http://libg.org/code/sample.sql" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">sql</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.sql</span></a></span></td>
</tr>
<tr>
<td width="97" valign="top"><strong>VB</strong></td>
<td width="97" valign="top">vb</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=vb&amp;url=http://libg.org/code/sample.vb" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">vb</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.vb</span></a></span></td>
</tr>
<tr>
<td width="97" valign="top"><strong>XML/HTML</strong></td>
<td width="97" valign="top">xml</td>
<td width="367" valign="top"><span style="color: #000080;"><a href="http://libg.org/code.php?lang=xml&amp;url=http://libg.org/code/sample.xml" target="_blank">http://libg.org/code.php?lang=<span style="color: #000080;">xml</span>&amp;url=<span style="color: #000080;">http://libg.org/code/sample.xml</span></a></span></td>
</tr>
</tbody>
</table>
<p>You can use the form below to test LibG Code Viewer:</p>
<form action="http://libg.org/code.php" target="_blank" enctype="application/x-www-form-urlencoded" method="get">
<table border="1" cellspacing="0" cellpadding="2" width="537">
<tbody>
<tr>
<td width="146" valign="top">Language:</td>
<td width="377" valign="top">
<select name="lang">
<option selected="selected" value="cpp">C++</option>
<option value="csharp">C#</option>
<option value="css">CSS</option>
<option value="delphi">Delphi</option>
<option value="java">Java</option>
<option value="js">Java Script</option>
<option value="php">PHP</option>
<option value="py">Python</option>
<option value="ruby">Ruby</option>
<option value="sql">SQL</option>
<option value="vb">Visual Basic</option>
<option value="xml">XML/HTML</option>
</select>
</td>
</tr>
<tr>
<td width="146" valign="top">Source Code Link:</td>
<td width="377" valign="top">
<input id="url" name="url" size="50" type="text" /></td>
</tr>
<tr>
<td colspan="2" valign="top" align="center">
<div>
<input name="Submit" size="20" type="submit" value="Submit" /></div>
</td>
</tr>
</tbody>
</table>
</form>
<img src="http://feeds.feedburner.com/~r/libg/~4/zHra3qbUJ-M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://libg.org/2008/09/14/show-formatted-source-code-with-syntax-highlight/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://libg.org/2008/09/14/show-formatted-source-code-with-syntax-highlight/</feedburner:origLink></item>
		<item>
		<title>How to format source code in your blog</title>
		<link>http://feedproxy.google.com/~r/libg/~3/XcIiOrAr3ms/</link>
		<comments>http://libg.org/2008/09/11/how-to-format-source-code-in-your-blog/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 11:59:00 +0000</pubDate>
		<dc:creator>Mason</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://libg.org/2008/09/11/how-to-format-source-code-in-your-blog/</guid>
		<description><![CDATA[When I was writing my post Include Guard: #pragma once vs. #ifndef #define #endif, I searched from Internet and tried at least 5 WordPress plug-in to insert formatted source code. But none of them works well for me. Some can not support C++ source code, some insert complicated html code to my post. Finally I [...]]]></description>
			<content:encoded><![CDATA[<p>When I was writing my post <a href="http://libg.org/2008/09/06/include-guard-pragma-once-vs-ifdef-define-endif/" target="_blank"><em>Include Guard: #pragma once vs. #ifndef #define #endif</em></a>, I searched from Internet and tried at least 5 WordPress plug-in to insert formatted source code. But none of them works well for me. Some can not support C++ source code, some insert complicated html code to my post. Finally I found <a href="http://code.google.com/p/syntaxhighlighter/" target="_blank">syntax highlighting</a> is simply and easy to prettify my code. There is WordPress plug-in <a href="http://wordpress.org/extend/plugins/google-syntax-highlighter/" target="_blank">Google Syntax Highlighter for WordPress</a>, and convenient for WordPress users to integrate to your WordPress blog site. The plug-in author may be wrong here, because the true Google Code highlight tool is <a href="http://code.google.com/p/google-code-prettify/" target="_blank">Google Code Prettify</a>.</p>
<p>SyntaxHighlighter is a pure JavaScript based tool and can parse a lot of programming languages:</p>
<ul>
<li>C++ (cpp, c, c++) </li>
<li>C# (c#, c-sharp, csharp) </li>
<li>CSS (css) </li>
<li>Delphi (delphi, pascal) </li>
<li>Java (java) </li>
<li>Java Script (js, jscript, javascript) </li>
<li>PHP (php) </li>
<li>Python (py, python) </li>
<li>Ruby (rb, ruby, rails, ror) </li>
<li>Sql (sql) </li>
<li>VB (vb, vb.net) </li>
<li>XML/HTML (xml, html, xhtml, xslt) </li>
</ul>
<p>To learn format your source code use this tool, please refer to the usage from <a href="http://code.google.com/p/syntaxhighlighter/wiki/Usage" target="_blank">http://code.google.com/p/syntaxhighlighter/wiki/Usage</a>. This post demonstrated the result of SyntaxHighlighter so you can make a quick decision. I used the code from Microsoft MSDN <a title="http://msdn.microsoft.com/en-us/library/w5c4hyx3(VS.80).aspx" href="http://msdn.microsoft.com/en-us/library/w5c4hyx3(VS.80).aspx" target="_blank">http://msdn.microsoft.com/en-us/library/w5c4hyx3(VS.80).aspx</a> as the sample code for testing.</p>
<p><strong>1. Default usage:</strong></p>
<p>&lt;pre name=&quot;code&quot; class=&quot;cpp&quot;&gt; &#8230; code here &#8230; &lt;/pre&gt;</p>
<p><u>Result:</u></p>
<pre class="cpp" name="code">// Exhibits polymorphism/virtual functions.

#include <iostream>
#include <string>
#define TRUE = 1
using namespace std;

class dog
{
public:
	// Source Code Omitted...

private:
   string _dogSize, _earType;
   int _legs;
   bool _bark;

};

class breed : public dog
{
public:
	/*
	Source Code Omitted...
	*/
};

int main()
{
   dog mongrel;
   breed labrador(&quot;yellow&quot;, &quot;large&quot;);
   mongrel.setEars(&quot;pointy&quot;);
   labrador.setEars(&quot;long&quot;, &quot;floppy&quot;);
   cout &lt;&lt; &quot;Cody is a &quot; &lt;&lt; labrador.getColor() &lt;&lt; &quot; labrador&quot; &lt;&lt; endl;
}</pre>
<p><strong>2. Display no gutter:</strong></p>
<p>&lt;pre name=&quot;code&quot; class=&quot;cpp:<font color="#ff0000">nogutter</font>&quot;&gt; &#8230; code here &#8230; &lt;/pre&gt;</p>
<p><u>Result:</u></p>
<pre class="cpp:nogutter" name="code">// Exhibits polymorphism/virtual functions.

#include <iostream>
#include <string>
#define TRUE = 1
using namespace std;

class dog
{
public:
	// Source Code Omitted...

private:
   string _dogSize, _earType;
   int _legs;
   bool _bark;

};

class breed : public dog
{
public:
	/*
	Source Code Omitted...
	*/
};

int main()
{
   dog mongrel;
   breed labrador(&quot;yellow&quot;, &quot;large&quot;);
   mongrel.setEars(&quot;pointy&quot;);
   labrador.setEars(&quot;long&quot;, &quot;floppy&quot;);
   cout &lt;&lt; &quot;Cody is a &quot; &lt;&lt; labrador.getColor() &lt;&lt; &quot; labrador&quot; &lt;&lt; endl;
}</pre>
<p><strong>3. Display no controls at the top</strong></p>
<p>&lt;pre name=&quot;code&quot; class=&quot;cpp:<font color="#ff0000">nocontrols</font>&quot;&gt; &#8230; code here &#8230; &lt;/pre&gt;</p>
<p><u>Result</u></p>
<pre class="cpp:nocontrols" name="code">// Exhibits polymorphism/virtual functions.

#include <iostream>
#include <string>
#define TRUE = 1
using namespace std;

class dog
{
public:
	// Source Code Omitted...

private:
   string _dogSize, _earType;
   int _legs;
   bool _bark;

};

class breed : public dog
{
public:
	/*
	Source Code Omitted...
	*/
};

int main()
{
   dog mongrel;
   breed labrador(&quot;yellow&quot;, &quot;large&quot;);
   mongrel.setEars(&quot;pointy&quot;);
   labrador.setEars(&quot;long&quot;, &quot;floppy&quot;);
   cout &lt;&lt; &quot;Cody is a &quot; &lt;&lt; labrador.getColor() &lt;&lt; &quot; labrador&quot; &lt;&lt; endl;
}</pre>
<p><strong>4. Collapse the block by default</strong></p>
<p>&lt;pre name=&quot;code&quot; class=&quot;cpp:<font color="#ff0000">collapse</font>&quot;&gt; &#8230; code here &#8230; &lt;/pre&gt;</p>
<p><u>Result</u></p>
<pre class="cpp:collapse" name="code">// Exhibits polymorphism/virtual functions.

#include <iostream>
#include <string>
#define TRUE = 1
using namespace std;

class dog
{
public:
	// Source Code Omitted...

private:
   string _dogSize, _earType;
   int _legs;
   bool _bark;

};

class breed : public dog
{
public:
	/*
	Source Code Omitted...
	*/
};

int main()
{
   dog mongrel;
   breed labrador(&quot;yellow&quot;, &quot;large&quot;);
   mongrel.setEars(&quot;pointy&quot;);
   labrador.setEars(&quot;long&quot;, &quot;floppy&quot;);
   cout &lt;&lt; &quot;Cody is a &quot; &lt;&lt; labrador.getColor() &lt;&lt; &quot; labrador&quot; &lt;&lt; endl;
}</pre>
<p><strong>5. Begin line count at <tt>value</tt>. Default value is 1</strong></p>
<p>&lt;pre name=&quot;code&quot; class=&quot;cpp:<font color="#ff0000">firstline[123]</font>&quot;&gt; &#8230; code here &#8230; &lt;/pre&gt;</p>
<p><u>Result</u></p>
<pre class="cpp:firstline[123]" name="code">// Exhibits polymorphism/virtual functions.

#include <iostream>
#include <string>
#define TRUE = 1
using namespace std;

class dog
{
public:
	// Source Code Omitted...

private:
   string _dogSize, _earType;
   int _legs;
   bool _bark;

};

class breed : public dog
{
public:
	/*
	Source Code Omitted...
	*/
};

int main()
{
   dog mongrel;
   breed labrador(&quot;yellow&quot;, &quot;large&quot;);
   mongrel.setEars(&quot;pointy&quot;);
   labrador.setEars(&quot;long&quot;, &quot;floppy&quot;);
   cout &lt;&lt; &quot;Cody is a &quot; &lt;&lt; labrador.getColor() &lt;&lt; &quot; labrador&quot; &lt;&lt; endl;
}</pre>
<p><strong>6. Show row columns in the first line. </strong></p>
<p>&lt;pre name=&quot;code&quot; class=&quot;cpp:<font color="#ff0000">showcolumns</font>&quot;&gt; &#8230; code here &#8230; &lt;/pre&gt;</p>
<p><u>Result</u></p>
<pre class="cpp:showcolumns" name="code">// Exhibits polymorphism/virtual functions.

#include <iostream>
#include <string>
#define TRUE = 1
using namespace std;

class dog
{
public:
	// Source Code Omitted...

private:
   string _dogSize, _earType;
   int _legs;
   bool _bark;

};

class breed : public dog
{
public:
	/*
	Source Code Omitted...
	*/
};

int main()
{
   dog mongrel;
   breed labrador(&quot;yellow&quot;, &quot;large&quot;);
   mongrel.setEars(&quot;pointy&quot;);
   labrador.setEars(&quot;long&quot;, &quot;floppy&quot;);
   cout &lt;&lt; &quot;Cody is a &quot; &lt;&lt; labrador.getColor() &lt;&lt; &quot; labrador&quot; &lt;&lt; endl;
}</pre>
<p><u></u></p>
<p>If you are using WordPress plug-in, please be sure to remove redundant JavaScript files in your plug-in source code and speed up the page loading. Go to WordPress dashboard, Plugins -&gt; Plugin Editor, select &quot;Google Syntax Highlighter for WordPress&quot;, go to the bottom of the source code, I removed the similar lines to the line below and kept this line to highlight CPP code:</p>
<p>&lt;script class=&quot;javascript&quot; src=&quot;&lt;?php echo $current_path; ?&gt;Scripts/<font color="#ff0000"><strong>shBrushCpp</strong></font>.js&quot;&gt;&lt;/script&gt;</p>
<img src="http://feeds.feedburner.com/~r/libg/~4/XcIiOrAr3ms" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://libg.org/2008/09/11/how-to-format-source-code-in-your-blog/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://libg.org/2008/09/11/how-to-format-source-code-in-your-blog/</feedburner:origLink></item>
		<item>
		<title>Performance: encapsulate floating point and built-in tolerance</title>
		<link>http://feedproxy.google.com/~r/libg/~3/TcHzlzZTjlo/</link>
		<comments>http://libg.org/2008/09/11/performance-encapsulate-floating-point-and-built-in-tolerance/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 07:57:49 +0000</pubDate>
		<dc:creator>Mason</dc:creator>
				<category><![CDATA[General C++]]></category>
		<category><![CDATA[Numeral]]></category>

		<guid isPermaLink="false">http://libg.org/2008/09/11/performance-encapsulate-floating-point-and-built-in-tolerance/</guid>
		<description><![CDATA[When it comes to the floating point comparison with tolerance, two approaches come into my mind. The first approach is to write inline functions and call them when compare floating point numbers. It is easy to understand and is widely used by numerous applications. Yes, it is really simple and I like it. The only [...]]]></description>
			<content:encoded><![CDATA[<p>When it comes to the floating point comparison with tolerance, two approaches come into my mind.</p>
<p>The first approach is to write inline functions and call them when compare floating point numbers. It is easy to understand and is widely used by numerous applications. Yes, it is really simple and I like it. The only concern is that I have to call these functions explicitly when compare two float or double variables, and I have to be aware of the code where it is necessary to compare with tolerance.</p>
<p>The second approach is to encapsulation floating point using a class. A float variable is the only member variable and I have to override lots of operators, assignment operator, relational and equality operators to control flow, arithmetic, unary, prefix and postfix operators. But how to implement the class is not a big deal, I&#8217;m worrying about the performance decrease which is introduced by using classes instead of pure machine data type.</p>
<p>Then I write the first to my open source library LibG, and made unit test for performance. The result looks good to me.</p>
<p><span style="text-decoration: underline">Testing Environment      <br /></span>Hardware1: CPU: AMD Sempron 2600+ (1.6G Hz). Memory: 1G, DDR400     <br />Hardware2: CPU: Intel Core2 6300 (1.86G Hz). Memory: 4G    <br />Software: Windows XP Professional with SP2</p>
<p><span style="text-decoration: underline">Testing Method</span>     <br />Repeat 15million times of a set of operations. There are one additional assignment, one comparison and one pre-decrement to complete the loop. Run 10 times and get average time.</p>
<p><span style="text-decoration: underline">Source Code      <br /></span>Open source portal of LibG: <a title="http://code.google.com/p/libg/" href="http://code.google.com/p/libg/">http://code.google.com/p/libg/</a>     <br />The class giFloat and giDouble: <a title="http://code.google.com/p/libg/source/browse/trunk/inc/gifloat.h" href="http://code.google.com/p/libg/source/browse/trunk/inc/gifloat.h">http://code.google.com/p/libg/source/browse/trunk/inc/gifloat.h</a>     <br />The testing code: <span style="text-decoration: underline"><a title="http://code.google.com/p/libg/source/browse/trunk/test/libg_unit_test/test_gifloat.cpp" href="http://code.google.com/p/libg/source/browse/trunk/test/libg_unit_test/test_gifloat.cpp">http://code.google.com/p/libg/source/browse/trunk/test/libg_unit_test/test_gifloat.cpp</a></span></p>
<p><span style="text-decoration: underline">Testing Result      <br /></span>1. Arithmetic Operations: Operations Set: +, -, *, /, +=, -=, *=, /=</p>
<table cellspacing="1" cellpadding="2" width="658" border="1">
<tbody>
<tr>
<td valign="top" align="center" width="146">Testing Result (ms)</td>
<td valign="top" align="center" width="118">float</td>
<td valign="top" align="center" width="129">giFloat</td>
<td valign="top" align="center" width="125">double</td>
<td valign="top" align="center" width="132">giDouble</td>
</tr>
<tr>
<td align="center" width="146">Hardware1</td>
<td valign="middle" align="center" width="118">856.3</td>
<td valign="middle" align="center" width="129">837.3</td>
<td valign="middle" align="center" width="125">336.1</td>
<td valign="middle" align="center" width="132">337.6</td>
</tr>
<tr>
<td align="center" width="146"><font color="#404040">Performance</font></td>
<td align="center" width="118">&#160;</td>
<td align="center" width="129"><span style="color: #008000">+2.22%</span></td>
<td valign="top" align="center" width="125">&#160;</td>
<td valign="top" align="center" width="132"><span style="color: #ff0000">-0.45%</span></td>
</tr>
<tr>
<td align="center" width="146">Hardware2</td>
<td align="center" width="118">517.2</td>
<td align="center" width="129">517.3</td>
<td valign="top" align="center" width="125">528.1</td>
<td valign="top" align="center" width="132">504.7</td>
</tr>
<tr>
<td align="center" width="146"><font color="#404040">Performance</font></td>
<td align="center" width="118">&#160;</td>
<td align="center" width="129"><font color="#ff0000">-0.02%</font></td>
<td valign="top" align="center" width="125">&#160;</td>
<td valign="top" align="center" width="132"><font color="#008000">+4.43%</font></td>
</tr>
</tbody>
</table>
<table cellspacing="0" cellpadding="2" width="657" border="0">
<tbody>
<tr>
<td valign="top" width="655">The performance of using class is very close to machine data type.</td>
</tr>
</tbody>
</table>
<p>2. Relational and Equality Operations: Operations Set: ==, !=, &gt;, &gt;=, &lt;, &lt;=</p>
<table cellspacing="1" cellpadding="2" width="657" border="1">
<tbody>
<tr>
<td align="center" width="103">Result</td>
<td align="center" width="90">float          <br />(no tolerance)</td>
<td align="center" width="105">float          <br />(inline functions)</td>
<td align="center" width="64">giFloat</td>
<td align="center" width="89">double          <br />(no tolerance)</td>
<td align="center" width="105">double          <br />(inline functions)</td>
<td align="center" width="90">giDouble</td>
</tr>
<tr>
<td valign="top" align="center" width="104">Hardware1</td>
<td valign="top" align="center" width="90">378.1</td>
<td valign="top" align="center" width="105">667.2</td>
<td valign="top" align="center" width="64">734.4</td>
<td valign="top" align="center" width="89">270.3</td>
<td valign="top" align="center" width="105">435.9</td>
<td valign="top" align="center" width="90">482.8</td>
</tr>
<tr>
<td align="center" width="105"><font color="#404040">Performance</font></td>
<td align="center" width="90">&#160;</td>
<td align="center" width="105">&#160;</td>
<td align="center" width="64"><span style="color: #ff0000">-10.07%</span></td>
<td align="center" width="89">&#160;</td>
<td align="center" width="105">&#160;</td>
<td align="center" width="90"><span style="color: #ff0000">-9.71%</span></td>
</tr>
<tr>
<td align="center" width="105">Hardware2</td>
<td align="center" width="90">165.6</td>
<td align="center" width="105">282.8</td>
<td align="center" width="64">312.7</td>
<td align="center" width="89">151.4</td>
<td align="center" width="105">237.7</td>
<td align="center" width="90">237.3</td>
</tr>
<tr>
<td align="center" width="105"><font color="#404040">Performance</font></td>
<td align="center" width="90">&#160;</td>
<td align="center" width="105">&#160;</td>
<td align="center" width="64"><font color="#ff0000">-9.56%</font></td>
<td align="center" width="89">&#160;</td>
<td align="center" width="105">&#160;</td>
<td align="center" width="90"><font color="#008000">+0.12%</font></td>
</tr>
</tbody>
</table>
<table cellspacing="0" cellpadding="2" width="657" border="0">
<tbody>
<tr>
<td valign="top" width="655">Comparing with using inline functions, the performance of using class decreased about 10%, it&#8217;s acceptable to me. The data type double is the most frequently used type on geometry computation, the performance result on Intel Core2 CPU is exciting.</td>
</tr>
</tbody>
</table>
<img src="http://feeds.feedburner.com/~r/libg/~4/TcHzlzZTjlo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://libg.org/2008/09/11/performance-encapsulate-floating-point-and-built-in-tolerance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://libg.org/2008/09/11/performance-encapsulate-floating-point-and-built-in-tolerance/</feedburner:origLink></item>
		<item>
		<title>Comparison of Float and Double Precision</title>
		<link>http://feedproxy.google.com/~r/libg/~3/6hUmntiGsZw/</link>
		<comments>http://libg.org/2008/09/07/comparison-of-float-and-double-precision/#comments</comments>
		<pubDate>Sun, 07 Sep 2008 08:50:33 +0000</pubDate>
		<dc:creator>Mason</dc:creator>
				<category><![CDATA[Numeral]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[floating point]]></category>

		<guid isPermaLink="false">http://libg.org/2008/09/07/comparison-of-float-and-double-precision/</guid>
		<description><![CDATA[C++ supports two primitive floating point types: float and double. These are based on the IEEE 754 standard, which defines a binary standard for 32-bit floating point and 64-bit double precision floating point binary-decimal numbers. IEEE 754 represents floating point numbers as base 2 decimal numbers in scientific notation. An IEEE floating point number dedicates [...]]]></description>
			<content:encoded><![CDATA[<p>C++ supports two primitive floating point types: <code>float</code> and <code>double</code>. These are based on the IEEE 754 standard, which defines a binary standard for 32-bit floating point and 64-bit double precision floating point binary-decimal numbers. IEEE 754 represents floating point numbers as base 2 decimal numbers in scientific notation. An IEEE floating point number dedicates 1 bit to the sign of the number, 8 bits to the exponent, and 23 bits to the mantissa, or fractional part. The exponent is interpreted as a signed integer, allowing negative as well as positive exponents. The fraction is represented as a binary (base 2) decimal, meaning the highest-order bit corresponds to a value of ½ (2<sup>-1</sup>), the second bit ¼ (2<sup>-2</sup>), and so on. For double-precision floating point, 11 bits are dedicated to the exponent and 52 bits to the mantissa. The layout of IEEE floating point values is shown in Figure 1.</p>
<p><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" src="http://libg.org/wp-content/uploads/2008/09/float1.gif" border="0" alt="float" width="579" height="177" /></p>
<p>Because any given number can be represented in scientific notation in multiple ways, floating point numbers are normalized so that they are represented as a base 2 decimal with a 1 to the left of the decimal point, adjusting the exponent as necessary to make this requirement hold. So, for example, the number 1.25 would be represented with a mantissa of 1.01 and an exponent of 0:<br />
<code>(-1) </code></p>
<p>The number 10.0 would be represented with a mantissa of 1.01 and an exponent of 3:<br />
<code>(-1)</code></p>
<table class="main" border="0" width="2">
<tbody>
<tr>
<td class="content" valign="top">
<div class="content2">
<p>here are some sample floating point representations:</p>
<pre>0      0x00000000
1.0    0x3f800000
0.5    0x3f000000
3      0x40400000
+inf   0x7f800000
-inf   0xff800000
+NaN   0x7fc00000 or 0x7ff00000
in general: number = (sign ? -1:1) * 2^(exponent) * 1.(mantissa bits)</pre>
<p>As a programmer, it is important to know certain characteristics of your FP representation. These are listed below, with example values for both single- and double-precision IEEE floating point numbers:</p>
<table border="1" cellpadding="2">
<tbody>
<tr>
<td><strong>Property </strong></td>
<td><strong>Value for float </strong></td>
<td><strong>Value for double </strong></td>
</tr>
<tr>
<td>Largest representable number</td>
<td>3.402823466e+38</td>
<td>1.7976931348623157e+308</td>
</tr>
<tr>
<td>Smallest number without losing precision</td>
<td>1.175494351e-38</td>
<td>2.2250738585072014e-308</td>
</tr>
<tr>
<td>Smallest representable number(*)</td>
<td>1.401298464e-45</td>
<td>5e-324</td>
</tr>
<tr>
<td>Mantissa bits</td>
<td>23</td>
<td>52</td>
</tr>
<tr>
<td>Exponent bits</td>
<td>8</td>
<td>11</td>
</tr>
<tr>
<td>Epsilon(**)</td>
<td>1.1929093e-7</td>
<td>2.220446049250313e-16</td>
</tr>
</tbody>
</table>
<p>Note that all numbers in the text of this article assume single-precision floats; doubles are included above for comparison and reference purposes.</p>
<p>(*)</p>
<p>Just to make life interesting, here we have yet another special case. It turns out that if you set the exponent bits to zero, you can represent numbers other than zero by setting mantissa bits. As long as we have an implied leading 1, the smallest number we can get is clearly 2^-126, so to get these lower values we make an exception. The &#8220;1.m&#8221; interpretation disappears, and the number&#8217;s magnitude is determined only by bit positions; if you shift the mantissa to the right, the apparent exponent will change (try it!). It may help clarify matters to point out that 1.401298464e-45 = 2^(-126-23), in other words the smallest exponent minus the number of mantissa bits.</p>
<p>However, as I have implied in the above table, when using these extra-small numbers you sacrifice precision. When there is no implied 1, all bits to the left of the lowest set bit are leading zeros, which add no information to a number (as you know, you can write zeros to the left of any number all day long if you want). Therefore the absolute smallest representable number (1.401298464e-45, with only the lowest bit of the FP word set) has an appalling mere single bit of precision!</p>
<p>(**)</p>
<p>Epsilon is the smallest x such that 1+x &gt; 1. It is the place value of the least significant bit when the exponent is zero (i.e., stored as 0x7f).</p></div>
</td>
</tr>
</tbody>
</table>
<img src="http://feeds.feedburner.com/~r/libg/~4/6hUmntiGsZw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://libg.org/2008/09/07/comparison-of-float-and-double-precision/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://libg.org/2008/09/07/comparison-of-float-and-double-precision/</feedburner:origLink></item>
	</channel>
</rss>

