title: Calculate Percent Increase and Decrease
body: <p>I'm likely over-thinking this, but I'm looking for something a bit more elegant than what I currently have.</p>
  
  <p>I have this method called <code>CalculatePercentageTrend</code>, which takes in a <code>long</code> "previous" value and "current" value. As it currently stands :</p>
  
  <pre><code>public static string CalculatePercentageTrend(long previousValue, long currentValue)
  {
      var trend = "0.00%";
  
      // calculate percentage increase
      if (previousValue &lt; currentValue)
      {
          if (previousValue != 0)
          {
              var difference = previousValue - currentValue;
              var pctDecrease = (double)(difference / previousValue) * 100;
              trend = pctDecrease.ToString("P");
          }
          else
          {
              trend = currentValue.ToString("P");
          }
       }
      // calculate percentage decrease
      else if (currentValue &lt; previousValue)
      {
          if (previousValue != 0)
          {
              var difference = currentValue - previousValue;
              var pctIncrease = (double)(difference / previousValue) * 100;
              trend = pctIncrease.ToString("P");
          }
          else
          {
              trend = currentValue.ToString("P");
          }
      }
      return trend;
  }
  </code></pre>
  
  <p>This feels very repetitive, and has a few short comings. Negative trends aren't calculated properly, as they always result in a 0.00% change - what would be great is if I could get a negative percentage IF in fact the previous value is greater than the current value. </p>
  
  <p>Also, I'm handling any possible 0's before dividing, but I'm wondering if there's a better approach to that as well.</p>
  
  <p><strong>My Question :</strong></p>
  
  <p>How can I get negative percentages to calculate correctly, and how can I improve this code overall?</p>