<?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>Perplexed Labs &#187; rounding</title>
	<atom:link href="http://blog.perplexedlabs.com/tag/rounding/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.perplexedlabs.com</link>
	<description>web development war stories from the frontlines to the backend</description>
	<lastBuildDate>Thu, 09 Sep 2010 17:11:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>JavaScript roundTo Nearest Thousandth, Hundredth, Tenth, *</title>
		<link>http://blog.perplexedlabs.com/2009/02/06/javascript-roundto-nearest-thousandth-hundredth-tenth/</link>
		<comments>http://blog.perplexedlabs.com/2009/02/06/javascript-roundto-nearest-thousandth-hundredth-tenth/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 18:53:42 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[round]]></category>
		<category><![CDATA[rounding]]></category>

		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=153</guid>
		<description><![CDATA[This very simple function does exactly what the title suggests, it allows you to round to any specified accuracy. function roundTo(number, to) { return Math.round(number * to) / to; } alert(roundTo(1532, 100)); // 1500 alert(roundTo(26, 10)); // 30 If you want to get fancy, you could also modify the Number prototype for a more "integrated" [...]


Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2008/11/12/javascript-event-handler/' rel='bookmark' title='Permanent Link: JavaScript Event Handler'>JavaScript Event Handler</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/11/07/real-time-ajax-javascript-progress-bar/' rel='bookmark' title='Permanent Link: Real-time &#8220;AJAX&#8221; JavaScript Progress Bar'>Real-time &#8220;AJAX&#8221; JavaScript Progress Bar</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/' rel='bookmark' title='Permanent Link: PHP jQuery AJAX Javascript Long Polling'>PHP jQuery AJAX Javascript Long Polling</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This very simple function does exactly what the title suggests, it allows you to round to any specified accuracy.</p>
<pre class="brush: jscript;">
function roundTo(number, to) {
	return Math.round(number * to) / to;
}

alert(roundTo(1532, 100)); // 1500
alert(roundTo(26, 10)); // 30
</pre>
<p>If you want to get fancy, you could also modify the Number prototype for a more "integrated" solution.</p>
<pre class="brush: jscript;">
Number.prototype.roundTo = function(to) {
	return Math.round(this * to) / to;
}
</pre>


<p>Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2008/11/12/javascript-event-handler/' rel='bookmark' title='Permanent Link: JavaScript Event Handler'>JavaScript Event Handler</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/11/07/real-time-ajax-javascript-progress-bar/' rel='bookmark' title='Permanent Link: Real-time &#8220;AJAX&#8221; JavaScript Progress Bar'>Real-time &#8220;AJAX&#8221; JavaScript Progress Bar</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/' rel='bookmark' title='Permanent Link: PHP jQuery AJAX Javascript Long Polling'>PHP jQuery AJAX Javascript Long Polling</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.perplexedlabs.com/2009/02/06/javascript-roundto-nearest-thousandth-hundredth-tenth/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
