예제 #1
0
 /// <summary>
 /// Overflow safe addition of two number values.
 ///
 /// Will not overflow but instead widen the type as necessary. </summary>
 /// <param name="a"> left-hand operand </param>
 /// <param name="b"> right-hand operand </param>
 /// <returns> a + b </returns>
 public static NumberValue OverflowSafeAdd(NumberValue a, NumberValue b)
 {
     if (a is IntegralValue && b is IntegralValue)
     {
         return(OverflowSafeAdd(a.LongValue(), b.LongValue()));
     }
     else
     {
         return(a.Plus(b));
     }
 }