<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Brian Zhang Larsen's Blog &#187; code</title>
	<atom:link href="http://www.bluespot.dk/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bluespot.dk</link>
	<description></description>
	<lastBuildDate>Sat, 15 May 2010 14:00:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>On floating-point numbers</title>
		<link>http://www.bluespot.dk/2006/10/07/on-floating-point-numbers/</link>
		<comments>http://www.bluespot.dk/2006/10/07/on-floating-point-numbers/#comments</comments>
		<pubDate>Sat, 07 Oct 2006 12:56:26 +0000</pubDate>
		<dc:creator>Brian Zhang Larsen</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.bluespot.dk/2006/10/07/on-floating-point-numbers/</guid>
		<description><![CDATA[While skimming Steve McConnell&#8217;s Code Complete, second edition, the morning after the Chinese mid-autumn day (Alcohol was involved), I found an interesting point that I was not aware off. The preciseness of a 32-bit floating point is very disappointing (pardon the pun). 
I wrote this simple piece of code in Java: 
double sum=0.0;
for(int i=0;i]]></description>
			<content:encoded><![CDATA[<p>While skimming Steve McConnell&#8217;s Code Complete, second edition, the morning after the Chinese mid-autumn day (Alcohol was involved), I found an interesting point that I was not aware off. The preciseness of a 32-bit floating point is very disap<em>point</em>ing (pardon the pun). </p>
<p>I wrote this simple piece of code in Java: </p>
<p><code>double sum=0.0;<br />
for(int i=0;i<10;i++){<br />
&nbsp;&nbsp;sum+=0.1;<br />
&nbsp;&nbsp;System.out.println(sum);<br />
}</code></p>
<p>The outcome of this is:</p>
<p><code>0.1<br />
0.2<br />
0.30000000000000004<br />
0.4<br />
0.5<br />
0.6<br />
0.7<br />
0.7999999999999999<br />
0.8999999999999999<br />
0.9999999999999999</code></p>
<p>I think the Danish tax office has used to many floating-point numbers to calculate Vivians tax, since they already made 4 mistakes this year . </p>
<p>The <em>point</em> is, don't trust anyone :O </p>
]]></content:encoded>
			<wfw:commentRss>http://www.bluespot.dk/2006/10/07/on-floating-point-numbers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
