<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Comments on snippet: 'Convert String to Number in Javascript'</title>
<link>http://snipplr.com</link>
<description>Snipplr comments feed'</description>
<language>en-us</language>
<pubDate>Fri, 05 Sep 2008 01:53:32 GMT</pubDate>
<item>
<title>darkphotn said on 1/13/08</title>
<link>http://snipplr.com/view/4531/convert-string-to-number-in-javascript/</link>
<description><![CDATA[ <p>Original code modified -- the new method is based on inamorix's, and is better than the original (and also better than tps's).</p>

<p>tpsreport, that link is dead.  Check the page.</p>
 ]]></description>
<pubDate>Sun, 13 Jan 2008 16:01:45 GMT</pubDate>
<guid>http://snipplr.com/view/4531/convert-string-to-number-in-javascript/</guid>
</item>
<item>
<title>darkphotn said on 1/13/08</title>
<link>http://snipplr.com/view/4531/convert-string-to-number-in-javascript/</link>
<description><![CDATA[ <p>This is a quick and dirty one-line hack that works.  </p>

<p>A more professional method would be:</p>

<p>function $n (n) {
   return (typeof(n) == 'number') ? new Number(n) : NaN;
} // originally posted by inamorix </p>
 ]]></description>
<pubDate>Sun, 13 Jan 2008 15:51:06 GMT</pubDate>
<guid>http://snipplr.com/view/4531/convert-string-to-number-in-javascript/</guid>
</item>
<item>
<title>tpsreport said on 1/13/08</title>
<link>http://snipplr.com/view/4531/convert-string-to-number-in-javascript/</link>
<description><![CDATA[ <p>Do <em>not</em> use this code!  This is amateur-level fail.  Javascript has plenty of type-casting functions available that do this properly.  </p>

<p>Given an input value of <code>x</code>, you can do the following: </p>


<code>parseInt(x, 10) // returns x as an integer in base 10</code>
<code>parseInt(x, 16) // returns x as an integer in hex</code>
<code>parseFloat(x) // returns x as a float</code>


<p>See the Mozilla reference docs here:
http://developer.mozilla.org/en/docs/Core<em>JavaScript</em>1.5<em>Guide:Predefined</em>Functions:parseInt<em>and</em>parseFloat_Functions</p>
 ]]></description>
<pubDate>Sun, 13 Jan 2008 14:52:36 GMT</pubDate>
<guid>http://snipplr.com/view/4531/convert-string-to-number-in-javascript/</guid>
</item>
</channel>
</rss>