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

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

            return operation.Left.IsZero()
                ? CreateZero()
                : CreateOne();
        }
예제 #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
            );
        }
예제 #4
0
 // ReSharper disable once UnusedParameter.Local
 private static EquationTermBase ProcessMultiplication(EquationBinaryOperationBase operation) =>
     CreateZero();
예제 #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 &&
예제 #8
0
 private static decimal Right(EquationBinaryOperationBase operation) => Value(operation.Right);
예제 #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 &&