<?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: JavaScript round float to n decimal points</title>
	<atom:link href="http://www.kadimi.com/en/round-float-349/feed" rel="self" type="application/rss+xml" />
	<link>http://www.kadimi.com/en/round-float-349</link>
	<description>[Web developper, Linux addict, Technical translator...]</description>
	<lastBuildDate>Sat, 07 Jan 2012 07:53:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Nabil</title>
		<link>http://www.kadimi.com/en/round-float-349#comment-255</link>
		<dc:creator>Nabil</dc:creator>
		<pubDate>Wed, 06 Apr 2011 17:20:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.kadimi.com/en/?p=349#comment-255</guid>
		<description>This is very clean, if val is not a number the function will return NaN (Not a Number)

Thanks Chat!</description>
		<content:encoded><![CDATA[<p>This is very clean, if val is not a number the function will return NaN (Not a Number)</p>
<p>Thanks Chat!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chat</title>
		<link>http://www.kadimi.com/en/round-float-349#comment-254</link>
		<dc:creator>Chat</dc:creator>
		<pubDate>Wed, 06 Apr 2011 16:24:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.kadimi.com/en/?p=349#comment-254</guid>
		<description>make it simpler
function round(val, prec)
{
	return parseFloat(parseFloat(val).toFixed(prec));
}</description>
		<content:encoded><![CDATA[<p>make it simpler<br />
function round(val, prec)<br />
{<br />
	return parseFloat(parseFloat(val).toFixed(prec));<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dmitry</title>
		<link>http://www.kadimi.com/en/round-float-349#comment-89</link>
		<dc:creator>Dmitry</dc:creator>
		<pubDate>Mon, 16 Aug 2010 03:18:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.kadimi.com/en/?p=349#comment-89</guid>
		<description>It would be better to use prototyping here. Newer browsers support toFixed() function. Older don&#039;t.
So here&#039;s the way to do it:

if (!Number.toFixed) {
Number.prototype.toFixed=function(x) {
   var temp=this;
   temp=Math.round(temp*Math.pow(10,x))/Math.pow(10,x);
   return temp;
}}

example:

f=123.23453

window.alert(f.toFixed(2));</description>
		<content:encoded><![CDATA[<p>It would be better to use prototyping here. Newer browsers support toFixed() function. Older don&#8217;t.<br />
So here&#8217;s the way to do it:</p>
<p>if (!Number.toFixed) {<br />
Number.prototype.toFixed=function(x) {<br />
   var temp=this;<br />
   temp=Math.round(temp*Math.pow(10,x))/Math.pow(10,x);<br />
   return temp;<br />
}}</p>
<p>example:</p>
<p>f=123.23453</p>
<p>window.alert(f.toFixed(2));</p>
]]></content:encoded>
	</item>
</channel>
</rss>

