<?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: How to format numbers in JavaScript flexibly and efficiently</title>
	<atom:link href="http://www.xaprb.com/blog/2006/01/05/javascript-number-formatting/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xaprb.com/blog/2006/01/05/javascript-number-formatting/</link>
	<description>Stay curious!</description>
	<lastBuildDate>Thu, 09 Feb 2012 09:56:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Name</title>
		<link>http://www.xaprb.com/blog/2006/01/05/javascript-number-formatting/#comment-19442</link>
		<dc:creator>Name</dc:creator>
		<pubDate>Tue, 21 Jun 2011 11:50:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=74#comment-19442</guid>
		<description>JavaScript has built-in methods to format a number to a certain precision. They are toFixed and toPrecision, and are part of the Number object. Any browser that supports ECMAScript version 3 should support toFixed and toPrecision. This roughly equates to Netscape 6.0 and above and IE 5.5 and above.</description>
		<content:encoded><![CDATA[<p>JavaScript has built-in methods to format a number to a certain precision. They are toFixed and toPrecision, and are part of the Number object. Any browser that supports ECMAScript version 3 should support toFixed and toPrecision. This roughly equates to Netscape 6.0 and above and IE 5.5 and above.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Felix</title>
		<link>http://www.xaprb.com/blog/2006/01/05/javascript-number-formatting/#comment-16565</link>
		<dc:creator>Felix</dc:creator>
		<pubDate>Wed, 17 Jun 2009 20:21:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=74#comment-16565</guid>
		<description>Great!...realy usefull!, thanks</description>
		<content:encoded><![CDATA[<p>Great!&#8230;realy usefull!, thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TQ</title>
		<link>http://www.xaprb.com/blog/2006/01/05/javascript-number-formatting/#comment-15683</link>
		<dc:creator>TQ</dc:creator>
		<pubDate>Fri, 16 Jan 2009 08:19:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=74#comment-15683</guid>
		<description>THANK YOU!</description>
		<content:encoded><![CDATA[<p>THANK YOU!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeferson Zanim</title>
		<link>http://www.xaprb.com/blog/2006/01/05/javascript-number-formatting/#comment-15614</link>
		<dc:creator>Jeferson Zanim</dc:creator>
		<pubDate>Tue, 30 Dec 2008 16:58:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=74#comment-15614</guid>
		<description>To correct the problem found by Heath change the old method by this new one:

Number.prototype.round = function(decimals) {
    if (decimals &gt; 0) {
        var m = this.toFixed(decimals + 1).match(
            new RegExp(&quot;(-?\\d*)\.(\\d{&quot; + decimals + &quot;})(\\d)\\d*$&quot;));
        if (m &amp;&amp; m.length) {
			var mathRoundedValue = Math.round(m[2] + &quot;.&quot; + m[3]);
			var paddedValue = String.leftPad(mathRoundedValue, decimals, &quot;0&quot;);
			if (paddedValue.length &gt; decimals) {
				m[1] = ((new Number(m[1])) + 1).toString();
				paddedValue = paddedValue.toString().substring(1);
			}
            return new Number(m[1] + &quot;.&quot; + paddedValue);
        }
    }
    return this;
}</description>
		<content:encoded><![CDATA[<p>To correct the problem found by Heath change the old method by this new one:</p>
<p>Number.prototype.round = function(decimals) {<br />
    if (decimals &gt; 0) {<br />
        var m = this.toFixed(decimals + 1).match(<br />
            new RegExp(&#8220;(-?\\d*)\.(\\d{&#8221; + decimals + &#8220;})(\\d)\\d*$&#8221;));<br />
        if (m &amp;&amp; m.length) {<br />
			var mathRoundedValue = Math.round(m[2] + &#8220;.&#8221; + m[3]);<br />
			var paddedValue = String.leftPad(mathRoundedValue, decimals, &#8220;0&#8243;);<br />
			if (paddedValue.length &gt; decimals) {<br />
				m[1] = ((new Number(m[1])) + 1).toString();<br />
				paddedValue = paddedValue.toString().substring(1);<br />
			}<br />
            return new Number(m[1] + &#8220;.&#8221; + paddedValue);<br />
        }<br />
    }<br />
    return this;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abraham</title>
		<link>http://www.xaprb.com/blog/2006/01/05/javascript-number-formatting/#comment-15565</link>
		<dc:creator>Abraham</dc:creator>
		<pubDate>Mon, 15 Dec 2008 20:23:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=74#comment-15565</guid>
		<description>We recently came across this great number-formatter  JavaScript.  We immediately jumped on to it and we are using it.  However, our company requires that displaying and rounding to function in a similar way as that of MS Excel. To be more specific, we want 2.3 using the format #.#### to be formatted as 2.3 not as 2.3000.  But 2.3 should be displayed as 2.3000 if the format is #.#000.

Does any body has a solution or a suggestion for this?
Thanks.</description>
		<content:encoded><![CDATA[<p>We recently came across this great number-formatter  JavaScript.  We immediately jumped on to it and we are using it.  However, our company requires that displaying and rounding to function in a similar way as that of MS Excel. To be more specific, we want 2.3 using the format #.#### to be formatted as 2.3 not as 2.3000.  But 2.3 should be displayed as 2.3000 if the format is #.#000.</p>
<p>Does any body has a solution or a suggestion for this?<br />
Thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

