<?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: Once and for all: Do not use double for money</title>
	<atom:link href="http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/feed/" rel="self" type="application/rss+xml" />
	<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/</link>
	<description></description>
	<lastBuildDate>Wed, 09 May 2012 22:39:34 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: andrew</title>
		<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/comment-page-1/#comment-341153</link>
		<dc:creator>andrew</dc:creator>
		<pubDate>Mon, 11 Oct 2010 17:43:12 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/01/11/once-and-for-all-do-not-use-double-for-money/#comment-341153</guid>
		<description>Hi Stephan,
This is a good point which I try to adhere to in my applications, but I am curious how you deal with performance issues associated with large sets of data. BigDecimal does not perform well when you have 1+ million calculations to do consistently (like multiple times for every execution of the application). This is a real life scenario I am describing. Have you found anything that utilizes banker&#039;s rounding but still comes close to the performance of operating on primitive doubles?</description>
		<content:encoded><![CDATA[<p>Hi Stephan,<br />
This is a good point which I try to adhere to in my applications, but I am curious how you deal with performance issues associated with large sets of data. BigDecimal does not perform well when you have 1+ million calculations to do consistently (like multiple times for every execution of the application). This is a real life scenario I am describing. Have you found anything that utilizes banker&#8217;s rounding but still comes close to the performance of operating on primitive doubles?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ger</title>
		<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/comment-page-1/#comment-285539</link>
		<dc:creator>Ger</dc:creator>
		<pubDate>Wed, 21 Apr 2010 20:56:26 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/01/11/once-and-for-all-do-not-use-double-for-money/#comment-285539</guid>
		<description>Today I came back to this posting. I&#039;m maintaining an app made by other people no longer in the company, and there is an issue with money rounding - they used Double. I&#039;m so pissed off I have to deal with this!!!
So yeah folks, I guess this posting is great advice.</description>
		<content:encoded><![CDATA[<p>Today I came back to this posting. I&#8217;m maintaining an app made by other people no longer in the company, and there is an issue with money rounding &#8211; they used Double. I&#8217;m so pissed off I have to deal with this!!!<br />
So yeah folks, I guess this posting is great advice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/comment-page-1/#comment-226234</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Fri, 27 Feb 2009 14:16:07 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/01/11/once-and-for-all-do-not-use-double-for-money/#comment-226234</guid>
		<description>Alex: Sure?

Looking at page 491 of Patterns of Enterprise Application Architecture he explicitly discourages the use of floats and suggests using long (See google book search).</description>
		<content:encoded><![CDATA[<p>Alex: Sure?</p>
<p>Looking at page 491 of Patterns of Enterprise Application Architecture he explicitly discourages the use of floats and suggests using long (See google book search).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/comment-page-1/#comment-226231</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Fri, 27 Feb 2009 13:46:58 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/01/11/once-and-for-all-do-not-use-double-for-money/#comment-226231</guid>
		<description>funny enough, but Fowler did use double for money amount in his examples :-)</description>
		<content:encoded><![CDATA[<p>funny enough, but Fowler did use double for money amount in his examples :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FEZ</title>
		<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/comment-page-1/#comment-48945</link>
		<dc:creator>FEZ</dc:creator>
		<pubDate>Mon, 14 Jan 2008 16:18:34 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/01/11/once-and-for-all-do-not-use-double-for-money/#comment-48945</guid>
		<description>http://en.wikipedia.org/wiki/Rounding#Round-to-even_method:

&quot;The origin of the term bankers&#039; rounding is more obscure. If this rounding method was ever a standard in banking, the evidence has proved extremely difficult to find. To the contrary, section 2 of the European Commission report The Introduction of the Euro and the Rounding of Currency Amounts [2] suggests that there had previously been no standard approach to rounding in banking.&quot;</description>
		<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Rounding#Round-to-even_method" rel="nofollow">http://en.wikipedia.org/wiki/Rounding#Round-to-even_method</a>:</p>
<p>&#8220;The origin of the term bankers&#8217; rounding is more obscure. If this rounding method was ever a standard in banking, the evidence has proved extremely difficult to find. To the contrary, section 2 of the European Commission report The Introduction of the Euro and the Rounding of Currency Amounts [2] suggests that there had previously been no standard approach to rounding in banking.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BigDecimal money cookbook at Stephans Blog</title>
		<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/comment-page-1/#comment-48919</link>
		<dc:creator>BigDecimal money cookbook at Stephans Blog</dc:creator>
		<pubDate>Mon, 14 Jan 2008 12:55:59 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/01/11/once-and-for-all-do-not-use-double-for-money/#comment-48919</guid>
		<description>[...] No signal, no noise.           &#171; Once and for all: Do not use double for money [...]</description>
		<content:encoded><![CDATA[<p>[...] No signal, no noise.           &laquo; Once and for all: Do not use double for money [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/comment-page-1/#comment-48897</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Mon, 14 Jan 2008 10:00:53 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/01/11/once-and-for-all-do-not-use-double-for-money/#comment-48897</guid>
		<description>ROUND_HALF_EVEN is called fair rounding because it distributes the error. It&#039;s also called bankers rounding.

http://en.wikipedia.org/wiki/Rounding#Round-to-even_method

&quot;Rounding mode to round towards the &quot;nearest neighbor&quot; unless both neighbors are equidistant, in which case, round towards the even neighbor. Behaves as for ROUND_HALF_UP if the digit to the left of the discarded fraction is odd; behaves as for ROUND_HALF_DOWN if it&#039;s even. Note that this is the rounding mode that minimizes cumulative error when applied repeatedly over a sequence of calculations.&quot;

http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#ROUND_HALF_EVEN</description>
		<content:encoded><![CDATA[<p>ROUND_HALF_EVEN is called fair rounding because it distributes the error. It&#8217;s also called bankers rounding.</p>
<p><a href="http://en.wikipedia.org/wiki/Rounding#Round-to-even_method" rel="nofollow">http://en.wikipedia.org/wiki/Rounding#Round-to-even_method</a></p>
<p>&#8220;Rounding mode to round towards the &#8220;nearest neighbor&#8221; unless both neighbors are equidistant, in which case, round towards the even neighbor. Behaves as for ROUND_HALF_UP if the digit to the left of the discarded fraction is odd; behaves as for ROUND_HALF_DOWN if it&#8217;s even. Note that this is the rounding mode that minimizes cumulative error when applied repeatedly over a sequence of calculations.&#8221;</p>
<p><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#ROUND_HALF_EVEN" rel="nofollow">http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#ROUND_HALF_EVEN</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FEZ</title>
		<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/comment-page-1/#comment-48885</link>
		<dc:creator>FEZ</dc:creator>
		<pubDate>Mon, 14 Jan 2008 09:10:10 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/01/11/once-and-for-all-do-not-use-double-for-money/#comment-48885</guid>
		<description>I don&#039;t know about USA, but in Europe you would use ROUND_HALF_UP for money rounding!?</description>
		<content:encoded><![CDATA[<p>I don&#8217;t know about USA, but in Europe you would use ROUND_HALF_UP for money rounding!?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/comment-page-1/#comment-48880</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Mon, 14 Jan 2008 08:11:39 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/01/11/once-and-for-all-do-not-use-double-for-money/#comment-48880</guid>
		<description>@Greg: I have the same feeling. Developers using double or float do use the wrong type in most cases except for 3D graphics or statistics.</description>
		<content:encoded><![CDATA[<p>@Greg: I have the same feeling. Developers using double or float do use the wrong type in most cases except for 3D graphics or statistics.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Finds of the Week - December 13, 2008 &#187; Chinh Do</title>
		<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/comment-page-1/#comment-48868</link>
		<dc:creator>Finds of the Week - December 13, 2008 &#187; Chinh Do</dc:creator>
		<pubDate>Mon, 14 Jan 2008 06:36:25 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/01/11/once-and-for-all-do-not-use-double-for-money/#comment-48868</guid>
		<description>[...] Stephan advised to use the &quot;money&quot; data type to store currency amounts instead of doubles. For good reasons. [...]</description>
		<content:encoded><![CDATA[<p>[...] Stephan advised to use the &quot;money&quot; data type to store currency amounts instead of doubles. For good reasons. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Miller</title>
		<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/comment-page-1/#comment-48821</link>
		<dc:creator>Greg Miller</dc:creator>
		<pubDate>Mon, 14 Jan 2008 00:19:44 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/01/11/once-and-for-all-do-not-use-double-for-money/#comment-48821</guid>
		<description>Quote:
--------------------------
I always distribute as [3.33, 3.33, 3.33] and then deposit 0.01 into my own secret account.
--------------------------

Just make sure you don&#039;t mess up on some mundane detail like putting a decimal point in the wrong place.

But seriously, it&#039;s been my opinion for a while that using float or double should cause a compiler warning optionally suppressed by a compiler flag.   I believe the only place a typical programmer would run into floats being used correctly would be 3D graphics programming.</description>
		<content:encoded><![CDATA[<p>Quote:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
I always distribute as [3.33, 3.33, 3.33] and then deposit 0.01 into my own secret account.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Just make sure you don&#8217;t mess up on some mundane detail like putting a decimal point in the wrong place.</p>
<p>But seriously, it&#8217;s been my opinion for a while that using float or double should cause a compiler warning optionally suppressed by a compiler flag.   I believe the only place a typical programmer would run into floats being used correctly would be 3D graphics programming.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/comment-page-1/#comment-48673</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Sat, 12 Jan 2008 14:33:05 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/01/11/once-and-for-all-do-not-use-double-for-money/#comment-48673</guid>
		<description>The comic hero, I´m really honoured.

A lot of people tried this, most of them got caught when getting greedy :-)</description>
		<content:encoded><![CDATA[<p>The comic hero, I´m really honoured.</p>
<p>A lot of people tried this, most of them got caught when getting greedy :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Burke</title>
		<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/comment-page-1/#comment-48653</link>
		<dc:creator>Eric Burke</dc:creator>
		<pubDate>Sat, 12 Jan 2008 12:43:46 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/01/11/once-and-for-all-do-not-use-double-for-money/#comment-48653</guid>
		<description>I always distribute as [3.33, 3.33, 3.33] and then deposit 0.01 into my own secret account.</description>
		<content:encoded><![CDATA[<p>I always distribute as [3.33, 3.33, 3.33] and then deposit 0.01 into my own secret account.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/comment-page-1/#comment-48510</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Fri, 11 Jan 2008 15:06:18 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/01/11/once-and-for-all-do-not-use-double-for-money/#comment-48510</guid>
		<description>@digital.alterego: Fowler calls it allocate I guess. You have 3 people and need to distribute (allocate) 10 EUR to them. 10/3 = 3.33 in cents, which means 1 cent is lost. Distributing 10 EUR correctly will result in 3 buckets [3.33, 3.33, 3.34].</description>
		<content:encoded><![CDATA[<p>@digital.alterego: Fowler calls it allocate I guess. You have 3 people and need to distribute (allocate) 10 EUR to them. 10/3 = 3.33 in cents, which means 1 cent is lost. Distributing 10 EUR correctly will result in 3 buckets [3.33, 3.33, 3.34].</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: digital.alterego</title>
		<link>http://codemonkeyism.com/once-and-for-all-do-not-use-double-for-money/comment-page-1/#comment-48504</link>
		<dc:creator>digital.alterego</dc:creator>
		<pubDate>Fri, 11 Jan 2008 14:12:01 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/01/11/once-and-for-all-do-not-use-double-for-money/#comment-48504</guid>
		<description>What do you mean with &quot;Use a distribute algorithm to distribute money to severel slots without loosing cents.&quot;? Could you please explain this further? Anyway thanks for the links, good discussions there.</description>
		<content:encoded><![CDATA[<p>What do you mean with &#8220;Use a distribute algorithm to distribute money to severel slots without loosing cents.&#8221;? Could you please explain this further? Anyway thanks for the links, good discussions there.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)
Database Caching using disk
Object Caching 455/456 objects using disk

Served from: codemonkeyism.com @ 2012-05-21 18:30:53 -->
