<?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: Using floating point variables to represent money =&gt; not a good idea!</title>
	<atom:link href="http://jamescrisp.org/2007/02/25/using-floating-point-variables-to-represent-money-not-a-good-idea/feed/" rel="self" type="application/rss+xml" />
	<link>http://jamescrisp.org/2007/02/25/using-floating-point-variables-to-represent-money-not-a-good-idea/</link>
	<description>C#, .NET, Ruby, Rails, book reviews, mind hacks, Wing Chun and the occasional personal bit.</description>
	<lastBuildDate>Fri, 18 May 2012 00:35:26 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: James</title>
		<link>http://jamescrisp.org/2007/02/25/using-floating-point-variables-to-represent-money-not-a-good-idea/#comment-9537</link>
		<dc:creator>James</dc:creator>
		<pubDate>Wed, 10 Dec 2008 06:54:10 +0000</pubDate>
		<guid isPermaLink="false">http://jamescrisp.org/wordpress/?p=42#comment-9537</guid>
		<description>Thanks Michael, the title of this post should really be &quot;Using _base 2_ floating point variables to represent money =&gt; not a good idea!</description>
		<content:encoded><![CDATA[<p>Thanks Michael, the title of this post should really be "Using _base 2_ floating point variables to represent money =&gt; not a good idea!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Skelton</title>
		<link>http://jamescrisp.org/2007/02/25/using-floating-point-variables-to-represent-money-not-a-good-idea/#comment-9535</link>
		<dc:creator>Michael Skelton</dc:creator>
		<pubDate>Tue, 09 Dec 2008 18:15:24 +0000</pubDate>
		<guid isPermaLink="false">http://jamescrisp.org/wordpress/?p=42#comment-9535</guid>
		<description>The .NET decimal type is still a floating-point numeric, as it uses a variable scaling factor. It is the fact that the implied base of decimal&#039;s scaling factor is 10 (not 2) that exempts it from the accuracy limitations of the other floating-point data types in representing &quot;real&quot; numbers.</description>
		<content:encoded><![CDATA[<p>The .NET decimal type is still a floating-point numeric, as it uses a variable scaling factor. It is the fact that the implied base of decimal's scaling factor is 10 (not 2) that exempts it from the accuracy limitations of the other floating-point data types in representing "real" numbers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://jamescrisp.org/2007/02/25/using-floating-point-variables-to-represent-money-not-a-good-idea/#comment-113</link>
		<dc:creator>James</dc:creator>
		<pubDate>Wed, 22 Aug 2007 11:52:05 +0000</pubDate>
		<guid isPermaLink="false">http://jamescrisp.org/wordpress/?p=42#comment-113</guid>
		<description>Hi Ryan,

You could multiply the number by 10 to the power of the number of decimal places you are interested in, truncate the result and then divide it by the number of decimal places you are interested in. Eg, (x * 10000).truncate() / 10000.

Cheers,
James</description>
		<content:encoded><![CDATA[<p>Hi Ryan,</p>
<p>You could multiply the number by 10 to the power of the number of decimal places you are interested in, truncate the result and then divide it by the number of decimal places you are interested in. Eg, (x * 10000).truncate() / 10000.</p>
<p>Cheers,<br />
James</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: samar massaad</title>
		<link>http://jamescrisp.org/2007/02/25/using-floating-point-variables-to-represent-money-not-a-good-idea/#comment-111</link>
		<dc:creator>samar massaad</dc:creator>
		<pubDate>Tue, 21 Aug 2007 07:36:03 +0000</pubDate>
		<guid isPermaLink="false">http://jamescrisp.org/wordpress/?p=42#comment-111</guid>
		<description>what is the namespace for the currency variable</description>
		<content:encoded><![CDATA[<p>what is the namespace for the currency variable</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://jamescrisp.org/2007/02/25/using-floating-point-variables-to-represent-money-not-a-good-idea/#comment-67</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Tue, 29 May 2007 02:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://jamescrisp.org/wordpress/?p=42#comment-67</guid>
		<description>Using C#: You wouldn&#039;t happen to know a  nice way to truncate down from 7 decimal to 4 decimal places for example. &lt;br/&gt;&lt;br/&gt;All the Decimal members (in .NET 2.0) add a rounding aspect to any return values or only consider the integer component or round up. &lt;br/&gt;&lt;br/&gt;We see the options as:-&lt;br/&gt;1. A small amount of arithmetic to &#039;construct&#039; the correct output. (E.g. maybe rounding and then &#039;if&#039; either subtract or add a delta.)&lt;br/&gt;&lt;br/&gt;2. Casting to a string and then manipulating and then casting sub strings back.&lt;br/&gt;&lt;br/&gt;Neither of the above fell elegant though. &lt;br/&gt;&lt;br/&gt;P.S. Great blog, I&#039;ll be back to have a bit more of read especially the book reviews.&lt;br/&gt;&lt;br/&gt;Cheers&lt;br/&gt;Ryan</description>
		<content:encoded><![CDATA[<p>Using C#: You wouldn't happen to know a  nice way to truncate down from 7 decimal to 4 decimal places for example. </p>
<p>All the Decimal members (in .NET 2.0) add a rounding aspect to any return values or only consider the integer component or round up. </p>
<p>We see the options as:-<br />1. A small amount of arithmetic to 'construct' the correct output. (E.g. maybe rounding and then 'if' either subtract or add a delta.)</p>
<p>2. Casting to a string and then manipulating and then casting sub strings back.</p>
<p>Neither of the above fell elegant though. </p>
<p>P.S. Great blog, I'll be back to have a bit more of read especially the book reviews.</p>
<p>Cheers<br />Ryan</p>
]]></content:encoded>
	</item>
</channel>
</rss>

