<?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/"
	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>Comments on: &quot;Decimal&quot; .NET Type vs. &quot;Float&quot; and &quot;Double&quot; C/C++ Type</title>
	<atom:link href="http://gregs-blog.com/2007/12/10/dot-net-decimal-type-vs-float-type/feed/" rel="self" type="application/rss+xml" />
	<link>http://gregs-blog.com/2007/12/10/dot-net-decimal-type-vs-float-type/</link>
	<description>A Blog about Graphics Programming, Game Programming, Tips and Tricks</description>
	<lastBuildDate>Mon, 16 Jan 2012 05:05:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: ShariqShariq</title>
		<link>http://gregs-blog.com/2007/12/10/dot-net-decimal-type-vs-float-type/#comment-2426</link>
		<dc:creator><![CDATA[ShariqShariq]]></dc:creator>
		<pubDate>Fri, 25 Nov 2011 15:46:50 +0000</pubDate>
		<guid isPermaLink="false">http://gregdolleysblog.wordpress.com/2007/12/10/test-for-pocketpc/#comment-2426</guid>
		<description><![CDATA[&gt; So if you’re writing a financial application for a bank that has to be 100% accurate and performance is not a consideration, use the Decimal type. 

What does 100% accurate mean? To determine accuracy, you must also determine the precision. For example, if I divide 100 by 3 and state that the answer must be precise to the nearest integer (perhaps because my processor only supports this level of precision) then the answer is 33 and that&#039;s 100% accurate.

However, if I specify my precision to 3dp, then the answer is 33.333 (again, 100% accurate). 

A decimal type in C# has a precision of 28-29 significant figures (http://msdn.microsoft.com/en-us/library/364x0z75.aspx). The &quot;actual&quot; answer for 100/3 is 33 and an infinite number of 3&#039;s after the decimal point. The decimal type will truncate this to 25-26 3&#039;s. That&#039;s not the actual answer, it&#039;s an answer that&#039;s 100% accurate to 25-26 decimal places.

So...

Go ahead and use doubles (ie floating point numbers) and convert to decimal at the end. Just don&#039;t try comparing variables of type double with each other or you&#039;ll enter a world of pain.]]></description>
		<content:encoded><![CDATA[<p>&gt; So if you’re writing a financial application for a bank that has to be 100% accurate and performance is not a consideration, use the Decimal type. </p>
<p>What does 100% accurate mean? To determine accuracy, you must also determine the precision. For example, if I divide 100 by 3 and state that the answer must be precise to the nearest integer (perhaps because my processor only supports this level of precision) then the answer is 33 and that&#8217;s 100% accurate.</p>
<p>However, if I specify my precision to 3dp, then the answer is 33.333 (again, 100% accurate). </p>
<p>A decimal type in C# has a precision of 28-29 significant figures (<a href="http://msdn.microsoft.com/en-us/library/364x0z75.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/364x0z75.aspx</a>). The &#8220;actual&#8221; answer for 100/3 is 33 and an infinite number of 3&#8242;s after the decimal point. The decimal type will truncate this to 25-26 3&#8242;s. That&#8217;s not the actual answer, it&#8217;s an answer that&#8217;s 100% accurate to 25-26 decimal places.</p>
<p>So&#8230;</p>
<p>Go ahead and use doubles (ie floating point numbers) and convert to decimal at the end. Just don&#8217;t try comparing variables of type double with each other or you&#8217;ll enter a world of pain.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan</title>
		<link>http://gregs-blog.com/2007/12/10/dot-net-decimal-type-vs-float-type/#comment-2169</link>
		<dc:creator><![CDATA[Ivan]]></dc:creator>
		<pubDate>Fri, 28 Jan 2011 10:29:34 +0000</pubDate>
		<guid isPermaLink="false">http://gregdolleysblog.wordpress.com/2007/12/10/test-for-pocketpc/#comment-2169</guid>
		<description><![CDATA[Thank you. This was written in a way, so I even understood it :-) I just loved the example with base 2 vs base 10. Thanx a bunch]]></description>
		<content:encoded><![CDATA[<p>Thank you. This was written in a way, so I even understood it <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  I just loved the example with base 2 vs base 10. Thanx a bunch</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Floating Point Math &#171; Kaizen &#8211; Continuous Improvement</title>
		<link>http://gregs-blog.com/2007/12/10/dot-net-decimal-type-vs-float-type/#comment-1881</link>
		<dc:creator><![CDATA[Floating Point Math &#171; Kaizen &#8211; Continuous Improvement]]></dc:creator>
		<pubDate>Mon, 19 Jul 2010 03:57:51 +0000</pubDate>
		<guid isPermaLink="false">http://gregdolleysblog.wordpress.com/2007/12/10/test-for-pocketpc/#comment-1881</guid>
		<description><![CDATA[[...] Floating Point&#160;Math  Posted on July 19, 2010 by Manjunath Bhat   Made simple [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Floating Point&nbsp;Math  Posted on July 19, 2010 by Manjunath Bhat   Made simple [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hurf</title>
		<link>http://gregs-blog.com/2007/12/10/dot-net-decimal-type-vs-float-type/#comment-1715</link>
		<dc:creator><![CDATA[hurf]]></dc:creator>
		<pubDate>Wed, 27 Jan 2010 16:15:20 +0000</pubDate>
		<guid isPermaLink="false">http://gregdolleysblog.wordpress.com/2007/12/10/test-for-pocketpc/#comment-1715</guid>
		<description><![CDATA[&quot;Binary floating point is really an approximation of the true decimal number because it is base two (binary) instead of base 10 (decimal).&quot;

There are an infinite number of ways to represent numbers in binary format.  Among these, an infinite number of them allow a number exactly equal to .1 to be represented.  And, an infinite number fail to exactly represent .1.  The standard format for floating point numbers in binary fails to represent .1, but not because it&#039;s binary.

An object in computer memory, such as a .NET Decimal, will also fail to accurately represent some numbers, even if they are decimal--if not because its format explicitly limits the number of digits it can represent, as with a Float, then because it&#039;s stored in a physical device, and to represent some numbers it would need more memory than the device possessed.  Such a number, whose exact representation in some given decimal format would occupy many gigabytes, is unlikely to arise in banking...  but it does exist.

Also, decimal numbers are not &quot;our real-world numbering system&quot;.  The fact that humans happen to have ten fingers doesn&#039;t magically make one numbering system more real than others.

You&#039;re talking about a few specific, practical matters in a way that makes them sound mathematically universal.]]></description>
		<content:encoded><![CDATA[<p>&#8220;Binary floating point is really an approximation of the true decimal number because it is base two (binary) instead of base 10 (decimal).&#8221;</p>
<p>There are an infinite number of ways to represent numbers in binary format.  Among these, an infinite number of them allow a number exactly equal to .1 to be represented.  And, an infinite number fail to exactly represent .1.  The standard format for floating point numbers in binary fails to represent .1, but not because it&#8217;s binary.</p>
<p>An object in computer memory, such as a .NET Decimal, will also fail to accurately represent some numbers, even if they are decimal&#8211;if not because its format explicitly limits the number of digits it can represent, as with a Float, then because it&#8217;s stored in a physical device, and to represent some numbers it would need more memory than the device possessed.  Such a number, whose exact representation in some given decimal format would occupy many gigabytes, is unlikely to arise in banking&#8230;  but it does exist.</p>
<p>Also, decimal numbers are not &#8220;our real-world numbering system&#8221;.  The fact that humans happen to have ten fingers doesn&#8217;t magically make one numbering system more real than others.</p>
<p>You&#8217;re talking about a few specific, practical matters in a way that makes them sound mathematically universal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gregd1024</title>
		<link>http://gregs-blog.com/2007/12/10/dot-net-decimal-type-vs-float-type/#comment-1712</link>
		<dc:creator><![CDATA[gregd1024]]></dc:creator>
		<pubDate>Thu, 21 Jan 2010 17:43:31 +0000</pubDate>
		<guid isPermaLink="false">http://gregdolleysblog.wordpress.com/2007/12/10/test-for-pocketpc/#comment-1712</guid>
		<description><![CDATA[Eric - nice! NP.]]></description>
		<content:encoded><![CDATA[<p>Eric &#8211; nice! NP.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Braun</title>
		<link>http://gregs-blog.com/2007/12/10/dot-net-decimal-type-vs-float-type/#comment-1709</link>
		<dc:creator><![CDATA[Eric Braun]]></dc:creator>
		<pubDate>Thu, 14 Jan 2010 06:22:17 +0000</pubDate>
		<guid isPermaLink="false">http://gregdolleysblog.wordpress.com/2007/12/10/test-for-pocketpc/#comment-1709</guid>
		<description><![CDATA[Excellent. Saved me a long debugging session to find sum differences! Thank you.]]></description>
		<content:encoded><![CDATA[<p>Excellent. Saved me a long debugging session to find sum differences! Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Saurabh Vats</title>
		<link>http://gregs-blog.com/2007/12/10/dot-net-decimal-type-vs-float-type/#comment-1641</link>
		<dc:creator><![CDATA[Saurabh Vats]]></dc:creator>
		<pubDate>Tue, 29 Sep 2009 13:46:10 +0000</pubDate>
		<guid isPermaLink="false">http://gregdolleysblog.wordpress.com/2007/12/10/test-for-pocketpc/#comment-1641</guid>
		<description><![CDATA[Thanks a lot greg for this useful article very informative]]></description>
		<content:encoded><![CDATA[<p>Thanks a lot greg for this useful article very informative</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gregd1024</title>
		<link>http://gregs-blog.com/2007/12/10/dot-net-decimal-type-vs-float-type/#comment-1625</link>
		<dc:creator><![CDATA[gregd1024]]></dc:creator>
		<pubDate>Sat, 12 Sep 2009 22:53:11 +0000</pubDate>
		<guid isPermaLink="false">http://gregdolleysblog.wordpress.com/2007/12/10/test-for-pocketpc/#comment-1625</guid>
		<description><![CDATA[Keith - a while back I was thinking about how to do this; at first, I thought just to make a wrapper class around all the possible data types, but your link has a simpler solution (in the comment on Aug 26,16:21). Thanks for the link. :-)]]></description>
		<content:encoded><![CDATA[<p>Keith &#8211; a while back I was thinking about how to do this; at first, I thought just to make a wrapper class around all the possible data types, but your link has a simpler solution (in the comment on Aug 26,16:21). Thanks for the link. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith</title>
		<link>http://gregs-blog.com/2007/12/10/dot-net-decimal-type-vs-float-type/#comment-1611</link>
		<dc:creator><![CDATA[Keith]]></dc:creator>
		<pubDate>Wed, 02 Sep 2009 10:14:26 +0000</pubDate>
		<guid isPermaLink="false">http://gregdolleysblog.wordpress.com/2007/12/10/test-for-pocketpc/#comment-1611</guid>
		<description><![CDATA[Answer to this question  &lt;a href=&quot;http://stackoverflow.com/questions/1335873/how-to-temporarily-replace-one-primitive-type-with-another-when-compiling-to-diff&quot; title=&quot;here&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;]]></description>
		<content:encoded><![CDATA[<p>Answer to this question  <a href="http://stackoverflow.com/questions/1335873/how-to-temporarily-replace-one-primitive-type-with-another-when-compiling-to-diff" title="here" rel="nofollow">here</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith</title>
		<link>http://gregs-blog.com/2007/12/10/dot-net-decimal-type-vs-float-type/#comment-1609</link>
		<dc:creator><![CDATA[Keith]]></dc:creator>
		<pubDate>Wed, 26 Aug 2009 15:52:01 +0000</pubDate>
		<guid isPermaLink="false">http://gregdolleysblog.wordpress.com/2007/12/10/test-for-pocketpc/#comment-1609</guid>
		<description><![CDATA[Hi, great article! 
I have a set of classes where I need to compile them to use float, double or decimals depending on the target. Any ideas on how to easily swap all float references for doubles for example to compile two different targets? 

Using something like &quot;class MYNumber : Double&quot; so that it is only necessary to change one line of code does not work as Double is sealed, and obviously there is no #define in C#, so I am at a loss on how to do this apparently simple task!

Thanks.]]></description>
		<content:encoded><![CDATA[<p>Hi, great article!<br />
I have a set of classes where I need to compile them to use float, double or decimals depending on the target. Any ideas on how to easily swap all float references for doubles for example to compile two different targets? </p>
<p>Using something like &#8220;class MYNumber : Double&#8221; so that it is only necessary to change one line of code does not work as Double is sealed, and obviously there is no #define in C#, so I am at a loss on how to do this apparently simple task!</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

