<?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>Ink Grass &#187; JavaScript</title>
	<atom:link href="http://inkgrass.lazymoon.org/category/programming/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://inkgrass.lazymoon.org</link>
	<description>A blog about web design, programming, graphics and everything inbetween.</description>
	<lastBuildDate>Mon, 18 Jan 2010 14:13:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rounding To Grouping</title>
		<link>http://inkgrass.lazymoon.org/2007/11/03/rounding-to-grouping/</link>
		<comments>http://inkgrass.lazymoon.org/2007/11/03/rounding-to-grouping/#comments</comments>
		<pubDate>Sat, 03 Nov 2007 02:53:34 +0000</pubDate>
		<dc:creator>Lachlan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://inkgrass.lazymoon.org/2007/11/03/rounding-to-integers/</guid>
		<description><![CDATA[There may come a time when you have to round a number up or down to certain multiples of another number. Since us Australians haven&#8217;t had one-cent pieces in quite some time, most purchases are rounded up or down to multiples of five cents.
Enough of my side-story. Here&#8217;s some simple code to get the job [...]]]></description>
			<content:encoded><![CDATA[<p>There may come a time when you have to round a number up or down to certain multiples of another number. Since us Australians haven&#8217;t had one-cent pieces in quite some time, most purchases are rounded up or down to multiples of five cents.</p>
<p>Enough of my side-story. Here&#8217;s some simple code to get the job done:</p>
<p><strong>Java:</strong></p>
<pre>import java.lang.Math;

public float roundToGrouping(float number, float grouping) {
    return Math.round(number/grouping)*grouping;
}</pre>
<p><strong>PHP:</strong></p>
<pre>function roundToGrouping($number, $grouping) {
    return round($number/$grouping)*$grouping;
}</pre>
<p><strong>JavaScript:</strong></p>
<pre>function roundToGrouping(number, grouping) {
    return Math.round(number/grouping)*grouping;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://inkgrass.lazymoon.org/2007/11/03/rounding-to-grouping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
