Esempio n. 1
0
        public T Divide <T>(T a, T b)
        {
            switch (b)
            {
            case 0:
                throw new DivideByZeroException("Numerator is zero");

            case 0.0:
                throw new DivideByZeroException("Numerator is zero");

            case double.PositiveInfinity:
                throw new NotFiniteNumberException("Numerator is positive infinity");

            case double.NegativeInfinity:
                throw new NotFiniteNumberException("Numerator is negative infinity");

            default:
                switch (a)
                {
                case double.NegativeInfinity:
                    throw new NotFiniteNumberException("Denumerator is negative infinity");

                case double.PositiveInfinity:
                    throw new NotFiniteNumberException("Denumerator is positive infinity");

                default:
                    return(GenericMath <T> .Divide(a, b));
                }
            }
        }
Esempio n. 2
0
 public T Divide <T>(T num1, T num2)
 {
     if (num1.Equals(0) || num2.Equals(0))
     {
         throw new DivideByZeroException("You cannot divide by 0");
     }
     return(GenericMath <T> .Divide(num1, num2));
 }
Esempio n. 3
0
 public void DivideDouble()
 {
     Assert.AreEqual(14514.7 / 45.2, GenericMath.Divide(14514.7, 45.2));
 }
 public static T Divide <T>(T value1, T value2)
 {
     return(GenericMath <T> .Divide(value1, value2));
 }