Having an issue with large integer addition in JavaScript
<p>I'm just making a very simple program to convert binary numbers to decimal and vice versa.  In doing the decimal to binary conversion, I realized I was running across a weird error when I try and add a small number to a very large number.  For example, I would give my program input 220002 as a decimal and it would convert that number to the binary number 110101101101100020.  In debugging this, I realized at the very end it did 110101101101100000 + 10 , and the result was 110101101101100020.  </p>

<p>I'm so confused as to why this happened.  I'm not really sure, help would be appreciated.  It also did it with smaller numbers, such as sometimes it would do a large number in binary form + 1 it would not change the binary number at all.  Here is my code if it helps.</p>

<pre><code>$("#convertDecimalBinary").on("click", function() {
    var decimal = $("#inputDecimal").val();
    console.log(!isNaN(decimal));
    if(!isNaN(decimal)) {
      var binary = 0;
      var multiplier = 1;
      var num = 1;
      while(num * 2 &lt;= decimal) {
        num *= 2;
        multiplier *= 10;
      }
      while(decimal &gt; 0) {
        if(decimal - num &gt;= 0) {
          decimal -= num;
          binary += multiplier;
        }
        num /= 2;
        multiplier /= 10;
      }
      $("#inputBinary").val(binary);
    }
  })
</code></pre>