<?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>mcBachmann.de TechBlog &#187; JavaScript</title>
	<atom:link href="http://blog.mcbachmann.de/tag/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.mcbachmann.de</link>
	<description>Der Blog zur Website ;-)</description>
	<lastBuildDate>Wed, 11 Jan 2012 21:12:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>JavaScript: numbers with decimal (thousand) separator</title>
		<link>http://blog.mcbachmann.de/linux/programming/javascript-numbers-with-decimal-thousand-separator</link>
		<comments>http://blog.mcbachmann.de/linux/programming/javascript-numbers-with-decimal-thousand-separator#comments</comments>
		<pubDate>Wed, 17 Feb 2010 10:55:11 +0000</pubDate>
		<dc:creator>Sven Bachmann</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[WWW]]></category>

		<guid isPermaLink="false">http://blog.mcbachmann.de/?p=488</guid>
		<description><![CDATA[Today, I needed a JavaScript function that converts a number like 1234567 to something more beautiful like 1.234.567. And because I didn&#8217;t need to take notice of locale settings (like using a comma instead of a dot) most solutions on the web where just too much for me and I decided to write my own. [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I needed a JavaScript function that converts a number like 1234567 to something more beautiful like 1.234.567. And because I didn&#8217;t need to take notice of locale settings (like using a comma instead of a dot) most solutions on the web where just too much for me and I decided to write my own.<span id="more-488"></span></p>
<p>Mainly its a 3-liner, but packed in a function it becomes a little more. Feel free to use it for your own:</p>
<blockquote><p><code>function thousand_sep(nr) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;var nr_tmp = nr.toString();<br />
&nbsp;&nbsp;&nbsp;&nbsp;for (var dots = Math.ceil((nr_tmp.length / 3) - 1); dots > 0; dots--) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nr_tmp = nr_tmp.substr(0, nr_tmp.length - (dots * 3)) + '.' +<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nr_tmp.substring(nr_tmp.length - (dots * 3), nr_tmp.length);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;return (nr_tmp);<br />
}</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.mcbachmann.de/linux/programming/javascript-numbers-with-decimal-thousand-separator/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

