<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Is it correct procedure to store currency values in databases as cents (or other smallest denomination)?</title>
	<link>http://ask.metafilter.com/14931/Is-it-correct-procedure-to-store-currency-values-in-databases-as-cents-or-other-smallest-denomination/</link>
	<description>Comments on Ask MetaFilter post Is it correct procedure to store currency values in databases as cents (or other smallest denomination)?</description>
	<pubDate>Wed, 09 Feb 2005 08:47:20 -0800</pubDate>
	<lastBuildDate>Wed, 09 Feb 2005 08:47:20 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Is it correct procedure to store currency values in databases as cents (or other smallest denomination)?</title>
		<link>http://ask.metafilter.com/14931/Is-it-correct-procedure-to-store-currency-values-in-databases-as-cents-or-other-smallest-denomination</link>	
		<description>A long time ago, I was taught to store to currency values in databases as cents (or the local equivalent) to avoid rounding problems with floating point column types.  Is this a sound practice, or a bunch of hogwash?</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2005:site.14931</guid>
		<pubDate>Wed, 09 Feb 2005 08:39:25 -0800</pubDate>
		<dc:creator>alan</dc:creator>
		
			<category>currency</category>
		
			<category>database</category>
		
	</item> <item>
		<title>By: mendel</title>
		<link>http://ask.metafilter.com/14931/Is-it-correct-procedure-to-store-currency-values-in-databases-as-cents-or-other-smallest-denomination#256905</link>	
		<description>Yes. Well, &quot;don&apos;t store fixed-precision values as floating-point&quot; is sound practice, regardless of what those fixed-precision values represent. Most databases will have a fixed-point type, DECIMAL, that lets you avoid having to store things as integers.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.14931-256905</guid>
		<pubDate>Wed, 09 Feb 2005 08:47:20 -0800</pubDate>
		<dc:creator>mendel</dc:creator>
	</item><item>
		<title>By: SpecialK</title>
		<link>http://ask.metafilter.com/14931/Is-it-correct-procedure-to-store-currency-values-in-databases-as-cents-or-other-smallest-denomination#256934</link>	
		<description>Some databases also let you declare the precision of a float. Either way, if you&apos;re doing math, you should manually round in your application so that you know which way you&apos;re rounding. There is nothing worse than an application that handles money and rounds up in some places but rounds down in other random places.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.14931-256934</guid>
		<pubDate>Wed, 09 Feb 2005 09:10:00 -0800</pubDate>
		<dc:creator>SpecialK</dc:creator>
	</item><item>
		<title>By: grouse</title>
		<link>http://ask.metafilter.com/14931/Is-it-correct-procedure-to-store-currency-values-in-databases-as-cents-or-other-smallest-denomination#256946</link>	
		<description>Don&apos;t use binary floating point numbers to store financial numbers, regardless of the precision. If your system doesn&apos;t support decimal floating point, do as you have been doing by storing cents.&lt;br&gt;
&lt;br&gt;
The &lt;a href=&quot;http://www.python.org/peps/pep-0327.html&quot;&gt;Python Enhancement Proposal for its Decimal datatype&lt;/a&gt; explains some of the issues.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.14931-256946</guid>
		<pubDate>Wed, 09 Feb 2005 09:22:52 -0800</pubDate>
		<dc:creator>grouse</dc:creator>
	</item><item>
		<title>By: b1tr0t</title>
		<link>http://ask.metafilter.com/14931/Is-it-correct-procedure-to-store-currency-values-in-databases-as-cents-or-other-smallest-denomination#256956</link>	
		<description>Historically, integer math has been *much* faster than floating-point math.  Modern CPUs with Alitvec or MMX are reversing that trend, but the big iron back in the data center may not have the nifty PC style floating point units.&lt;br&gt;
&lt;br&gt;
Also, what everyone else has said about precision issues.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.14931-256956</guid>
		<pubDate>Wed, 09 Feb 2005 09:30:43 -0800</pubDate>
		<dc:creator>b1tr0t</dc:creator>
	</item><item>
		<title>By: grouse</title>
		<link>http://ask.metafilter.com/14931/Is-it-correct-procedure-to-store-currency-values-in-databases-as-cents-or-other-smallest-denomination#256978</link>	
		<description>Yeah, there&apos;s a caveat I should add to my previous answer: decimal floating point will be even slower than binary floating point.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.14931-256978</guid>
		<pubDate>Wed, 09 Feb 2005 10:00:17 -0800</pubDate>
		<dc:creator>grouse</dc:creator>
	</item><item>
		<title>By: Zed_Lopez</title>
		<link>http://ask.metafilter.com/14931/Is-it-correct-procedure-to-store-currency-values-in-databases-as-cents-or-other-smallest-denomination#257030</link>	
		<description>Related document: &lt;a href=&quot;http://www.stewartcalculus.com/data/default/upfiles/LiesCalcAndCompTold.pdf&quot;&gt;Lies My Calculator Told Me&lt;/a&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.14931-257030</guid>
		<pubDate>Wed, 09 Feb 2005 11:12:22 -0800</pubDate>
		<dc:creator>Zed_Lopez</dc:creator>
	</item><item>
		<title>By: AstroGuy</title>
		<link>http://ask.metafilter.com/14931/Is-it-correct-procedure-to-store-currency-values-in-databases-as-cents-or-other-smallest-denomination#257046</link>	
		<description>Most databases have a currency data type that is stored as a scaled integer so you don&apos;t have the issue of binary floating point rounding errors.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.14931-257046</guid>
		<pubDate>Wed, 09 Feb 2005 11:25:17 -0800</pubDate>
		<dc:creator>AstroGuy</dc:creator>
	</item><item>
		<title>By: knave</title>
		<link>http://ask.metafilter.com/14931/Is-it-correct-procedure-to-store-currency-values-in-databases-as-cents-or-other-smallest-denomination#257104</link>	
		<description>Hope your software isn&apos;t going to be used at a gas station, if you&apos;re using integer cents.  They all seem to charge something like $2.139 per gallon.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.14931-257104</guid>
		<pubDate>Wed, 09 Feb 2005 13:02:51 -0800</pubDate>
		<dc:creator>knave</dc:creator>
	</item><item>
		<title>By: patrickje</title>
		<link>http://ask.metafilter.com/14931/Is-it-correct-procedure-to-store-currency-values-in-databases-as-cents-or-other-smallest-denomination#257136</link>	
		<description>Hmmmm...most modern databases have a currency data type that should be accurate to the mill (1/100 of  cent).&lt;br&gt;
&lt;br&gt;
There are many, many, many places that price to the mill.&lt;br&gt;
&lt;br&gt;
I remember when I did an inventory/ordering system for a custom printing company, they priced things by the ream, or other such quanties, but often they did short runs, but used a ream price adjusted for quantity.  Which meant the per page price was often below $0.01, and into the mills.&lt;br&gt;
&lt;br&gt;
And when you do partial pricing of items, and don&apos;t use mills, if you do large volumes, the rounding errors will kill you.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.14931-257136</guid>
		<pubDate>Wed, 09 Feb 2005 13:53:35 -0800</pubDate>
		<dc:creator>patrickje</dc:creator>
	</item><item>
		<title>By: grouse</title>
		<link>http://ask.metafilter.com/14931/Is-it-correct-procedure-to-store-currency-values-in-databases-as-cents-or-other-smallest-denomination#257241</link>	
		<description>A &lt;a href=&quot;http://en.wikipedia.org/wiki/Mill_%28currency%29&quot;&gt;mill&lt;/a&gt; is a tenth of a cent, not a hundredth.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.14931-257241</guid>
		<pubDate>Wed, 09 Feb 2005 16:53:24 -0800</pubDate>
		<dc:creator>grouse</dc:creator>
	</item>
	</channel>
</rss>
