JavaScript - How To Detect Number As A Decimal (Including 1.0)
<p>It feels like I am missing something obvious here.  This has been asked a number of times - and the answer usually boils down to:</p>

<pre><code>var num = 4.5;
num % 1 === 0; // false - 4.5 is a decimal
</code></pre>

<p>But, this fails for </p>

<pre><code>var num = 1.0; // or 2.0, 3.0, ...
num % 1 // 0
</code></pre>

<p>Unfortunately, these doesn't work either</p>

<pre><code>num.toString() // 1
typeof num // "number"
</code></pre>

<p>I am writing a JavaScript color parsing library, and I want to process input differently if it is given as 1.0 or 1.  In my case, <code>1.0</code> really means 100% and <code>1</code> means 1.</p>

<p>Otherwise, both <code>rgb 1 1 1</code> and <code>rgb 1 255 255</code> will be parsed as <code>rgb 255 255 255</code> (since I am right now taking anything &lt;= 1 to mean a ratio). </p>
