<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Double Imprecision In .Net</title>
	<atom:link href="http://www.gringod.com/2006/02/01/double-imprecision-in-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gringod.com/2006/02/01/double-imprecision-in-net/</link>
	<description>Randomised nonsense.</description>
	<lastBuildDate>Fri, 04 Nov 2011 08:49:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: gringod</title>
		<link>http://www.gringod.com/2006/02/01/double-imprecision-in-net/comment-page-1/#comment-10777</link>
		<dc:creator>gringod</dc:creator>
		<pubDate>Thu, 23 Mar 2006 18:14:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.gringod.com/2006/02/01/double-imprecision-in-net/#comment-10777</guid>
		<description>Just because both VB6 and VB.Net implement IEEE 754 doesn&#039;t mean that they will produce the same error on the same calculation.  This is because their implementations of IEEE 754 is different.

What it means is that at some point in VB6 you will find similar behaviour to that which I have outlined above in VB.Net.

I think.</description>
		<content:encoded><![CDATA[<p>Just because both VB6 and VB.Net implement IEEE 754 doesn&#8217;t mean that they will produce the same error on the same calculation.  This is because their implementations of IEEE 754 is different.</p>
<p>What it means is that at some point in VB6 you will find similar behaviour to that which I have outlined above in VB.Net.</p>
<p>I think.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: May</title>
		<link>http://www.gringod.com/2006/02/01/double-imprecision-in-net/comment-page-1/#comment-10775</link>
		<dc:creator>May</dc:creator>
		<pubDate>Thu, 23 Mar 2006 12:10:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.gringod.com/2006/02/01/double-imprecision-in-net/#comment-10775</guid>
		<description>You said that : &quot;It comes from the internal representation of Doubles in the memory, and this is not specific to .Net, all real programming languages have a data type for binary floating point numbers that exhibits this behavior.&quot;

but If you can find the Double problem in .Net for a sample you can run it in VB6 for example :
4.4 * 3 = 13.2 on VB6 and 13.20000000000000001 in VB.net 

132 * 0.1 = 13.2 on VB6 and 13.20000000000000001 in VB.net 

the Double has same precision in VB6 and VB.Net this means that the problem is from .Net.</description>
		<content:encoded><![CDATA[<p>You said that : &#8220;It comes from the internal representation of Doubles in the memory, and this is not specific to .Net, all real programming languages have a data type for binary floating point numbers that exhibits this behavior.&#8221;</p>
<p>but If you can find the Double problem in .Net for a sample you can run it in VB6 for example :<br />
4.4 * 3 = 13.2 on VB6 and 13.20000000000000001 in VB.net </p>
<p>132 * 0.1 = 13.2 on VB6 and 13.20000000000000001 in VB.net </p>
<p>the Double has same precision in VB6 and VB.Net this means that the problem is from .Net.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olivier Dony</title>
		<link>http://www.gringod.com/2006/02/01/double-imprecision-in-net/comment-page-1/#comment-10627</link>
		<dc:creator>Olivier Dony</dc:creator>
		<pubDate>Fri, 17 Feb 2006 22:15:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.gringod.com/2006/02/01/double-imprecision-in-net/#comment-10627</guid>
		<description>This is in fact a not so &quot;unexpected result&quot;, even if it always suprising the first time you encounter it.
It comes from the internal representation of Doubles in the memory, and this is not specific to .Net, all real programming languages have a data type for binary floating point numbers that exhibits this behavior.
The technical standard for representing these numbers (IEEE 754) defines floating points numbers as basically signed integers multiplied by powers of two. When fractional, you can also consider them as integers divided by powers of two. Of course, only a few decimal numbers do have an exact representation in this standard.


Therefore such data types should not be used for financial applications, and typically when decimal calculations must be done and displayed to the user.

This is also the reason why there is usually a more suitable Decimal representation for such numbers in programming languages (Decimal in .NET, BigDecimal in Java, etc.). These alternative data type work with a power of ten and a given &quot;precision&quot;, which allows them to make decimal calculations as a human would do it.
However these data type are more complex, and    operations on these types are usually not implemented in hardware (while IEEE754 is).
That is why there is a (small) trade-off in using them, in memory and time.

You can find lots of information and examples about this by googling a bit. Or read the great website about Decimals maintained by Mike Colishaw, which explains it all:
http://www2.hursley.ibm.com/decimal/
(Use google&#039;s cache if it is down)</description>
		<content:encoded><![CDATA[<p>This is in fact a not so &#8220;unexpected result&#8221;, even if it always suprising the first time you encounter it.<br />
It comes from the internal representation of Doubles in the memory, and this is not specific to .Net, all real programming languages have a data type for binary floating point numbers that exhibits this behavior.<br />
The technical standard for representing these numbers (IEEE 754) defines floating points numbers as basically signed integers multiplied by powers of two. When fractional, you can also consider them as integers divided by powers of two. Of course, only a few decimal numbers do have an exact representation in this standard.</p>
<p>Therefore such data types should not be used for financial applications, and typically when decimal calculations must be done and displayed to the user.</p>
<p>This is also the reason why there is usually a more suitable Decimal representation for such numbers in programming languages (Decimal in .NET, BigDecimal in Java, etc.). These alternative data type work with a power of ten and a given &#8220;precision&#8221;, which allows them to make decimal calculations as a human would do it.<br />
However these data type are more complex, and    operations on these types are usually not implemented in hardware (while IEEE754 is).<br />
That is why there is a (small) trade-off in using them, in memory and time.</p>
<p>You can find lots of information and examples about this by googling a bit. Or read the great website about Decimals maintained by Mike Colishaw, which explains it all:<br />
<a href="http://www2.hursley.ibm.com/decimal/" rel="nofollow">http://www2.hursley.ibm.com/decimal/</a><br />
(Use google&#8217;s cache if it is down)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

