title: Check if calculation exceeds MaxValue
body: <p>I currently got the following method, which is returning me percent-values. For example for an item-price of $350,000 and a percentage of 7%, it returns 24,500.</p>
  
  <pre><code>    public static decimal GetPercentValue(decimal? percentage, decimal baseValue)
      {
          decimal result = 0m;
  
          if (percentage != null)
          {
              try
              {
                  result = Convert.ToDecimal(baseValue * percentage / 100m);
              }
              catch (OverflowException)
              {
                  result = 0;
                  Logger.Warn("OverflowException caught in GetPercentValue() - should better be handled UI-Sided!");
              }
          }
  
          return result;
      }
  </code></pre>
  
  <p>I don't think this is handled the right way, so is there any way to avoid an exception in this situation?</p>
  
  <p>An OverflowException is being thrown when a user enters an insane number like <code>999,999,999,999,999,999</code> and calculates <code>9999999999%</code> of it. This way I can't check <code>percentage</code> or <code>baseValue</code> for <code>&lt;= decimal.MaxValue</code> simply because they aren't... The calculation result itself then exceeds the decimal range.</p>