<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flassari.is &#187; short</title>
	<atom:link href="http://flassari.is/tag/short/feed/" rel="self" type="application/rss+xml" />
	<link>http://flassari.is</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 19 Jul 2010 16:09:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Number Format - Thousand Separator in AS3</title>
		<link>http://flassari.is/2009/08/number-format-thousand-separator-in-as3/</link>
		<comments>http://flassari.is/2009/08/number-format-thousand-separator-in-as3/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 21:25:36 +0000</pubDate>
		<dc:creator>Flassari</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[currency]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[quick]]></category>
		<category><![CDATA[separator]]></category>
		<category><![CDATA[short]]></category>
		<category><![CDATA[thousand]]></category>

		<guid isPermaLink="false">http://flassari.is/?p=166</guid>
		<description><![CDATA[I needed a quick function to do some number formatting for me: to seperate thousands by commas. It's unbelievable that there are no short functions out there (easily searchable), so I wrote my own and hope you'll enjoy [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a short number format function I wrote to easily paste in your code when needed. It&#8217;s really handy for currency formatting.<br />
The first parameter (number:*) can be a Number, int, uint or a String class instance.<br />
The last parameter (siStyle:Boolean) specifies whether to use the <a href="http://en.wikipedia.org/wiki/SI" target="_blank">International System of Units</a> or not. <a href="http://en.wikipedia.org/wiki/SI" target="_blank">SI units</a> have points between the thousands and a comma for the seperator (123.456.789,01). Putting siStyle as false reverses that behaviour (123,456,789.01).</p>
<pre class="brush: as">function numberFormat(number:*, maxDecimals:int = 2, forceDecimals:Boolean = false, siStyle:Boolean = true):String {
    var i:int = 0, inc:Number = Math.pow(10, maxDecimals), str:String = String(Math.round(inc * Number(number))/inc);
    var hasSep:Boolean = str.indexOf(".") == -1, sep:int = hasSep ? str.length : str.indexOf(".");
    var ret:String = (hasSep &#038;&#038; !forceDecimals ? "" : (siStyle ? "," : ".")) + str.substr(sep+1);
    if (forceDecimals) for (var j:int = 0; j <= maxDecimals - (str.length - (hasSep ? sep-1 : sep)); j++) ret += "0";
    while (i + 3 < (str.substr(0, 1) == "-" ? sep-1 : sep)) ret = (siStyle ? "." : ",") + str.substr(sep - (i += 3), 3) + ret;
    return str.substr(0, sep - i) + ret;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://flassari.is/2009/08/number-format-thousand-separator-in-as3/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
