<?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: Number Format - Thousand Separator in AS3</title>
	<atom:link href="http://flassari.is/2009/08/number-format-thousand-separator-in-as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://flassari.is/2009/08/number-format-thousand-separator-in-as3/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 26 Jul 2010 09:23:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Flassari</title>
		<link>http://flassari.is/2009/08/number-format-thousand-separator-in-as3/comment-page-1/#comment-52</link>
		<dc:creator>Flassari</dc:creator>
		<pubDate>Thu, 15 Apr 2010 22:15:34 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=166#comment-52</guid>
		<description>The formatting was done on purpose. I know it&#039;s massively compressed and horrible to read, but it&#039;s supposed to be small and convenient to paste into timeline or code. There were other resources which had dedicated classes which are easily changeable and commented (like for beginners) at the time I made this (and still are), but I didn&#039;t want a whole class when I just wanted something quick and small to insert into the timeline.
I also don&#039;t recommend this code for mass number processing since it is not at all optimized for speed, only compactness.</description>
		<content:encoded><![CDATA[<p>The formatting was done on purpose. I know it&#8217;s massively compressed and horrible to read, but it&#8217;s supposed to be small and convenient to paste into timeline or code. There were other resources which had dedicated classes which are easily changeable and commented (like for beginners) at the time I made this (and still are), but I didn&#8217;t want a whole class when I just wanted something quick and small to insert into the timeline.<br />
I also don&#8217;t recommend this code for mass number processing since it is not at all optimized for speed, only compactness.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bractar</title>
		<link>http://flassari.is/2009/08/number-format-thousand-separator-in-as3/comment-page-1/#comment-51</link>
		<dc:creator>bractar</dc:creator>
		<pubDate>Thu, 15 Apr 2010 21:44:18 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=166#comment-51</guid>
		<description>nice functionality but I hate your formatting. It isn&#039;t clear enough to be updated easily. You don&#039;t need to show that you can program like a nasa guy when you give a function on the web. Most people who will use your function will be beginners...
But thank you for sharing it</description>
		<content:encoded><![CDATA[<p>nice functionality but I hate your formatting. It isn&#8217;t clear enough to be updated easily. You don&#8217;t need to show that you can program like a nasa guy when you give a function on the web. Most people who will use your function will be beginners&#8230;<br />
But thank you for sharing it</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DanielSig</title>
		<link>http://flassari.is/2009/08/number-format-thousand-separator-in-as3/comment-page-1/#comment-38</link>
		<dc:creator>DanielSig</dc:creator>
		<pubDate>Wed, 30 Dec 2009 16:55:25 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=166#comment-38</guid>
		<description>Hey, I added a little tweak of mine to your function. What it does is that it indents the returning string with indentUnit so that the length of the string minus decimals becomes forceLength.

This can be useful when you intend to align a vertical list of numbers so that the decimal points are in a straight line.

Note: unless you specify the forceLength parameter as a uint higher than 0, this function behaves just like the original function made by Flassari.

&lt;pre class=&quot;brush: as&quot;&gt;function numberFormat(number:*, maxDecimals:int = 2, forceDecimals:Boolean = false, siStyle:Boolean = true, forceLength:uint = 0, indentUnit:String = &quot; &quot;):String {
	var i:int = 0, inc:Number = Math.pow(10, maxDecimals), str:String = String(Math.round(inc * Number(number))/inc), indent:String = &quot;&quot;;
	var hasSep:Boolean = str.indexOf(&quot;.&quot;) == -1, sep:int = hasSep ? str.length : str.indexOf(&quot;.&quot;);
	var ret:String = (hasSep &amp;&amp; !forceDecimals ? &quot;&quot; : (siStyle ? &quot;,&quot; : &quot;.&quot;)) + str.substr(sep+1);
	if (forceDecimals) for (var j:int = 0; j &lt;= maxDecimals - (str.length - (hasSep ? sep-1 : sep)); j++) ret += &quot;0&quot;;
	while (i + 3 &lt; (str.substr(0, 1) == &quot;-&quot; ? sep-1 : sep)) ret = (siStyle ? &quot;.&quot; : &quot;,&quot;) + str.substr(sep - (i += 3), 3) + ret;
	if(forceLength != 0) for(j = sep + i / 3; j &lt; forceLength; j++) indent += indentUnit;
	return indent + str.substr(0, sep - i) + ret;
}&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hey, I added a little tweak of mine to your function. What it does is that it indents the returning string with indentUnit so that the length of the string minus decimals becomes forceLength.</p>
<p>This can be useful when you intend to align a vertical list of numbers so that the decimal points are in a straight line.</p>
<p>Note: unless you specify the forceLength parameter as a uint higher than 0, this function behaves just like the original function made by Flassari.</p>
<pre class="brush: as">function numberFormat(number:*, maxDecimals:int = 2, forceDecimals:Boolean = false, siStyle:Boolean = true, forceLength:uint = 0, indentUnit:String = " "):String {
	var i:int = 0, inc:Number = Math.pow(10, maxDecimals), str:String = String(Math.round(inc * Number(number))/inc), indent:String = "";
	var hasSep:Boolean = str.indexOf(".") == -1, sep:int = hasSep ? str.length : str.indexOf(".");
	var ret:String = (hasSep &amp;&amp; !forceDecimals ? "" : (siStyle ? "," : ".")) + str.substr(sep+1);
	if (forceDecimals) for (var j:int = 0; j &lt;= maxDecimals - (str.length - (hasSep ? sep-1 : sep)); j++) ret += &quot;0&quot;;
	while (i + 3 &lt; (str.substr(0, 1) == &quot;-&quot; ? sep-1 : sep)) ret = (siStyle ? &quot;.&quot; : &quot;,&quot;) + str.substr(sep - (i += 3), 3) + ret;
	if(forceLength != 0) for(j = sep + i / 3; j &lt; forceLength; j++) indent += indentUnit;
	return indent + str.substr(0, sep - i) + ret;
}</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Torben</title>
		<link>http://flassari.is/2009/08/number-format-thousand-separator-in-as3/comment-page-1/#comment-36</link>
		<dc:creator>Torben</dc:creator>
		<pubDate>Tue, 24 Nov 2009 11:24:32 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=166#comment-36</guid>
		<description>Great, thanks Flassari</description>
		<content:encoded><![CDATA[<p>Great, thanks Flassari</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flassari</title>
		<link>http://flassari.is/2009/08/number-format-thousand-separator-in-as3/comment-page-1/#comment-35</link>
		<dc:creator>Flassari</dc:creator>
		<pubDate>Fri, 20 Nov 2009 13:31:41 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=166#comment-35</guid>
		<description>Torben, I found the error you were talking about; it only happened when you passed in whole numbers.
It&#039;s been fixed now, thanks for spotting it =)</description>
		<content:encoded><![CDATA[<p>Torben, I found the error you were talking about; it only happened when you passed in whole numbers.<br />
It&#8217;s been fixed now, thanks for spotting it =)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Torben</title>
		<link>http://flassari.is/2009/08/number-format-thousand-separator-in-as3/comment-page-1/#comment-34</link>
		<dc:creator>Torben</dc:creator>
		<pubDate>Fri, 20 Nov 2009 13:00:07 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=166#comment-34</guid>
		<description>I don&#039;t see what was wrong with your original Deciaml code. When I test it your first line works - the second ads one decimal too many.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t see what was wrong with your original Deciaml code. When I test it your first line works - the second ads one decimal too many.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nizzle</title>
		<link>http://flassari.is/2009/08/number-format-thousand-separator-in-as3/comment-page-1/#comment-24</link>
		<dc:creator>nizzle</dc:creator>
		<pubDate>Sat, 31 Oct 2009 10:33:28 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=166#comment-24</guid>
		<description>Thanks, I was just looking for something like this. Nice code, also.</description>
		<content:encoded><![CDATA[<p>Thanks, I was just looking for something like this. Nice code, also.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flassari</title>
		<link>http://flassari.is/2009/08/number-format-thousand-separator-in-as3/comment-page-1/#comment-23</link>
		<dc:creator>Flassari</dc:creator>
		<pubDate>Wed, 21 Oct 2009 10:11:16 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=166#comment-23</guid>
		<description>No, that&#039;s what the &lt;strong&gt;siStyle&lt;/strong&gt; property is for, you can actually choose the metric SI style (default true because of majority) or non-SI style (false) that&#039;s in use in &lt;a href=&quot;http://en.wikipedia.org/wiki/SI&quot; rel=&quot;nofollow&quot;&gt;mostly Burma (Myanmar), Liberia, and the United States&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>No, that&#8217;s what the <strong>siStyle</strong> property is for, you can actually choose the metric SI style (default true because of majority) or non-SI style (false) that&#8217;s in use in <a href="http://en.wikipedia.org/wiki/SI" rel="nofollow">mostly Burma (Myanmar), Liberia, and the United States</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://flassari.is/2009/08/number-format-thousand-separator-in-as3/comment-page-1/#comment-22</link>
		<dc:creator>John</dc:creator>
		<pubDate>Tue, 20 Oct 2009 21:37:11 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=166#comment-22</guid>
		<description>You&#039;ve also got the comma and decimal around the wrong way.</description>
		<content:encoded><![CDATA[<p>You&#8217;ve also got the comma and decimal around the wrong way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flassari</title>
		<link>http://flassari.is/2009/08/number-format-thousand-separator-in-as3/comment-page-1/#comment-20</link>
		<dc:creator>Flassari</dc:creator>
		<pubDate>Fri, 09 Oct 2009 18:06:46 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=166#comment-20</guid>
		<description>Aaah, you&#039;re absolutely right! It&#039;s fixed now.

To hold onto compactness I changed
&lt;pre class=&quot;brush: as&quot;&gt;for (var j:int = 0; j &lt; maxDecimals - (str.length - sep); j++)&lt;/pre&gt;
to
&lt;pre class=&quot;brush: as&quot;&gt;for (var j:int = 0; j &lt;= maxDecimals - (str.length - sep); j++)&lt;/pre&gt;

Thanks for spotting that =)</description>
		<content:encoded><![CDATA[<p>Aaah, you&#8217;re absolutely right! It&#8217;s fixed now.</p>
<p>To hold onto compactness I changed</p>
<pre class="brush: as">for (var j:int = 0; j < maxDecimals - (str.length - sep); j++)</pre>
<p>to
</pre>
<pre class="brush: as">for (var j:int = 0; j < = maxDecimals - (str.length - sep); j++)</pre>
<p>Thanks for spotting that =)</pre>
]]></content:encoded>
	</item>
</channel>
</rss>
