<?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: Extend Math.round, Math.ceil and Math.floor to allow for precision</title>
	<atom:link href="http://lea.verou.me/2009/02/extend-mathround-mathceil-and-mathfloor-to-allow-precision/feed/" rel="self" type="application/rss+xml" />
	<link>http://lea.verou.me/2009/02/extend-mathround-mathceil-and-mathfloor-to-allow-precision/</link>
	<description>Life at the bleeding edge (of web standards)</description>
	<lastBuildDate>Fri, 10 Feb 2012 07:25:15 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Lea Verou</title>
		<link>http://lea.verou.me/2009/02/extend-mathround-mathceil-and-mathfloor-to-allow-precision/#comment-108</link>
		<dc:creator>Lea Verou</dc:creator>
		<pubDate>Wed, 01 Apr 2009 03:33:03 +0000</pubDate>
		<guid isPermaLink="false">http://leaverou.me/?p=27#comment-108</guid>
		<description>@alexiers: This is precisely what this post is about ;) You can just use the code I posted, or the one Rene Sarsoo posted and then you can do what you want by inputting the decimals as a second parameter. For instance Math.round(3.6789, 2) would return 3.68 after that.</description>
		<content:encoded><![CDATA[<p>@alexiers: This is precisely what this post is about <img src='http://lea.verou.me/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  You can just use the code I posted, or the one Rene Sarsoo posted and then you can do what you want by inputting the decimals as a second parameter. For instance Math.round(3.6789, 2) would return 3.68 after that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alexiers</title>
		<link>http://lea.verou.me/2009/02/extend-mathround-mathceil-and-mathfloor-to-allow-precision/#comment-107</link>
		<dc:creator>alexiers</dc:creator>
		<pubDate>Tue, 31 Mar 2009 23:11:50 +0000</pubDate>
		<guid isPermaLink="false">http://leaverou.me/?p=27#comment-107</guid>
		<description>I&#039;m still learning javascript. Mind if I ask some help?

You see, I want to change a value with multiple decimal to just two.
Let&#039;s say the value is 3.6789 and I just want to round it up to the first two decimal like 3.68.

How can it be done? I tried using math.round and ceil and floor but the values end up becoming integers instead.

Would be a big help if you could.</description>
		<content:encoded><![CDATA[<p>I&#8217;m still learning javascript. Mind if I ask some help?</p>
<p>You see, I want to change a value with multiple decimal to just two.<br />
Let&#8217;s say the value is 3.6789 and I just want to round it up to the first two decimal like 3.68.</p>
<p>How can it be done? I tried using math.round and ceil and floor but the values end up becoming integers instead.</p>
<p>Would be a big help if you could.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lea Verou</title>
		<link>http://lea.verou.me/2009/02/extend-mathround-mathceil-and-mathfloor-to-allow-precision/#comment-35</link>
		<dc:creator>Lea Verou</dc:creator>
		<pubDate>Mon, 09 Mar 2009 14:17:37 +0000</pubDate>
		<guid isPermaLink="false">http://leaverou.me/?p=27#comment-35</guid>
		<description>Thanks for commenting Rene and welcome to my blog!

Good point! Your solution is much better. 

I came up with this &quot;trick&quot; a long time ago and I wasn&#039;t really comfortable with closures at the time. I never really revised it since then. I&#039;ll do it your way from now on :)</description>
		<content:encoded><![CDATA[<p>Thanks for commenting Rene and welcome to my blog!</p>
<p>Good point! Your solution is much better. </p>
<p>I came up with this &#8220;trick&#8221; a long time ago and I wasn&#8217;t really comfortable with closures at the time. I never really revised it since then. I&#8217;ll do it your way from now on <img src='http://lea.verou.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rene Saarsoo</title>
		<link>http://lea.verou.me/2009/02/extend-mathround-mathceil-and-mathfloor-to-allow-precision/#comment-34</link>
		<dc:creator>Rene Saarsoo</dc:creator>
		<pubDate>Mon, 09 Mar 2009 13:00:14 +0000</pubDate>
		<guid isPermaLink="false">http://leaverou.me/?p=27#comment-34</guid>
		<description>Instead of storing standard Math.round to Math._round, why not hide it completely inside a closure:

&lt;pre&gt;Math.round = (function() {
  var oldRound = Math.round;
  return function(number, precision) {
    precision = Math.abs(parseInt(precision)) &#124;&#124; 0;
    var coefficient = Math.pow(10, precision);
    return oldRound(number*coefficient)/coefficient;
  };
})();&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Instead of storing standard Math.round to Math._round, why not hide it completely inside a closure:</p>
<pre>Math.round = (function() {
  var oldRound = Math.round;
  return function(number, precision) {
    precision = Math.abs(parseInt(precision)) || 0;
    var coefficient = Math.pow(10, precision);
    return oldRound(number*coefficient)/coefficient;
  };
})();</pre>
]]></content:encoded>
	</item>
</channel>
</rss>

