Esempio n. 1
0
        private static EquationTermBase ProcessDivision(EquationBinaryOperationBase operation)
        {
            if (operation.Right.IsZero())
            {
                throw new DevideByZeroInProcessingException();
            }

            return CreateZero();
        }
Esempio n. 2
0
        private static EquationTermBase ProcessExponentiation(EquationBinaryOperationBase operation)
        {
            if (operation.Left.IsZero() && operation.Right.IsZero())
            {
                throw new AttemptToCalculateZeroAtZeroDegreeException();
            }

            return operation.Left.IsZero()
                ? CreateZero()
                : CreateOne();
        }
Esempio n. 3
0
        private static EquationTermBase ProcessSubtraction(EquationBinaryOperationBase operation)
        {
            if (operation.Right.IsZero())
            {
                return operation.Left;
            }

            return new MultiplicationOperation(
                left: new EquationConstant(decimal.MinusOne),
                right: operation.Right
            );
        }
Esempio n. 4
0
 // ReSharper disable once UnusedParameter.Local
 private static EquationTermBase ProcessMultiplication(EquationBinaryOperationBase operation) =>
     CreateZero();
Esempio n. 5
0
 private static EquationTermBase ProcessAddition(EquationBinaryOperationBase operation) =>
     operation.Left.IsZero() ? operation.Right : operation.Left;
 private static bool MatchShiftRight(EquationBinaryOperationBase operation) =>
 operation.Left is EquationBinaryOperationBase leftOperation &&
 private static bool MatchShiftLeft(EquationBinaryOperationBase operation) =>
 operation.Right is EquationBinaryOperationBase rightOperation &&
Esempio n. 8
0
 private static decimal Right(EquationBinaryOperationBase operation) => Value(operation.Right);
Esempio n. 9
0
 private static decimal Left(EquationBinaryOperationBase operation) => Value(operation.Left);
 private static bool MatchShiftRight(EquationBinaryOperationBase operation) =>
 operation.Type == OperationsEnum.Addition &&
 operation.Left is EquationBinaryOperationBase leftOperation &&