title: What's the difference between abs and fabs?
body: <p>I checked the difference between <code>abs</code> and <code>fabs</code> on python <a href="https://stackoverflow.com/questions/21994052/abs-vs-fabs-speed-difference-and-advantage-of-fabs">here</a></p>
  
  <p>As I understand there are some difference regarding the speed and the passed types, but my question related to native c++ on V.S.</p>
  
  <p>Regarding the V.S.
  I tried the following on <code>Visual Studio 2013 (v120)</code>:</p>
  
  <pre><code>float f1= abs(-9.2); // f = 9.2
  float f2= fabs(-9); // Compile error [*]
  </code></pre>
  
  <p>So <code>fabs(-9)</code> it will give me a compiler error, but when I tried to do the following:</p>
  
  <pre><code>double i = -9;
  float f2= fabs(i); // This will work fine
  </code></pre>
  
  <p>What I understand from the first code that it will not compile because <code>fabs(-9)</code> need a double, and the compiler could not convert -9 to -9.0, but in the second code the compiler will convert <code>i=-9</code> to <code>i=-9.0</code> at compile time so <code>fabs(i)</code> will work fine.</p>
  
  <p>Any better explanation?</p>
  
  <p>Another thing, why the compiler can't accept  <code>fabs(-9)</code> and convert the int value to double automatically like what we have in c#?</p>
  
  <pre><code>[*]:
  
  Error: more than one instance of overloaded function "fabs" matches the argument list:
          function "fabs(double _X)"
          function "fabs(float _X)"
          function "fabs(long double _X)"
          argument types are: (int)   
  </code></pre>