title: Why is `abs()` implemented differently?
body: <p>I've had a super frustrating bug in my code for the past few weeks. My code would work exactly as expected on my computer, but as soon as I farmed it out to the HPC server, it would produce weird results.</p>
  
  <p>I've boiled it down to this: on my computer (iMac) the function <code>abs()</code> works with floating point numbers, but on the server <code>abs()</code> truncates it to an integer.</p>
  
  <p>Example:</p>
  
  <p>Server</p>
  
  <pre><code>abs(-1.1341234) = 1
  </code></pre>
  
  <p>My Mac</p>
  
  <pre><code>abs(-1.1341234) = 1.1341234
  </code></pre>
  
  <p>Now I know I can fix this by using <code>fabs()</code>, that's not the question. I looked at the versions of <code>gcc</code> on either machine and this is the output:</p>
  
  <p>Server</p>
  
  <pre><code>g++ -v
  Using built-in specs.
  COLLECT_GCC=g++
  COLLECT_LTO_WRAPPER=/apps/software/GCCcore/5.4.0/libexec/gcc/x86_64-unknown-linux-gnu/5.4.0/lto-wrapper
  Target: x86_64-unknown-linux-gnu
  Configured with: ../configure --enable-languages=c,c++,fortran --enable-lto --enable-checking=release --disable-multilib --enable-shared=yes --enable-static=yes --enable-threads=posix --enable-gold=default --enable-plugins --enable-ld --with-plugin-ld=ld.gold --prefix=/apps/software/GCCcore/5.4.0 --with-local-prefix=/apps/software/GCCcore/5.4.0 --enable-bootstrap --with-isl=/dev/shm/GCCcore/5.4.0/dummy-/gcc-5.4.0/stage2_stuff
  Thread model: posix
  gcc version 5.4.0 (GCC) 
  </code></pre>
  
  <p>My Mac</p>
  
  <pre><code>g++ -v
  Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
  Apple LLVM version 10.0.1 (clang-1001.0.46.3)
  Target: x86_64-apple-darwin18.5.0
  Thread model: posix
  InstalledDir: /Library/Developer/CommandLineTools/usr/bin
  </code></pre>
  
  <p>So my question, why does <code>abs()</code> produce different results between gcc and clang? This issue literally cost me 3 weeks of progress, so as you can imagine I'm a little salty just now...</p>