title: Fast and safe way to remove the sign of a singed number in JavaScript
body: <p>I want to remove the sign of a Number in JavaScript. <a href="http://jsperf.com/remove-sign-from-number" rel="nofollow noreferrer">Here are the test cases that I already examined at jsperf</a></p>
  <pre><code>if(n &lt; 0) n *= -1;
  
  if(n &lt; 0) n = -n;
  
  n = Math.abs(n)
  
  (n &lt; 0) &amp;&amp; (n *= -1)
  
  (n &lt; 0) &amp;&amp; (n = -n)
  
  n = Math.sqrt(n*n)
  </code></pre>
  <p>According to these tests: <code>if(n &lt; 0) n *= -1</code> seems to be a good solution.</p>
  <p>Do you know of any better, save, and more efficient way to do that?</p>
  <p><strong>Edit 1:</strong> Added Nikhil's <code>Math.sqrt</code> case, but <code>sqrt</code> is usually quite slow in most systems.</p>
  <p><strong>Edit 2:</strong> Jan's proposal for bitwise ops may be faster in some cases but will also remove fractional digits, and thus will not work for me.</p>