title: Shortest way to calculate difference between two numbers?
body: <p>I'm about to do this in C++ but I have had to do it in several languages, it's a fairly common and simple problem, and this is the last time. I've had enough of coding it as I do, I'm sure there must be a better method, so I'm posting here before I write out the same long winded method in yet another language;</p>
  
  <p>Consider the (<strike>lilies!</strike>) following code;</p>
  
  <pre><code>// I want the difference between these two values as a positive integer
  int x = 7
  int y = 3
  int diff;
  // This means you have to find the largest number first 
  // before making the subtract, to keep the answer positive
  if (x&gt;y) { 
       diff = (x-y);
  } else if (y&gt;x) {
       diff = (y-x);
  } else if (x==y) {
      diff = 0;
  }
  </code></pre>
  
  <p>This may sound petty but that seems like a lot to me, just to get the difference between two numbers. Is this in fact a completely reasonable way of doing things and I'm being unnecessarily pedantic, or is my spidey sense tingling with good reason?</p>