コード例 #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;
コード例 #6
0
 private static bool MatchShiftRight(EquationBinaryOperationBase operation) =>
 operation.Left is EquationBinaryOperationBase leftOperation &&
コード例 #7
0
 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);
コード例 #10
0
 private static bool MatchShiftRight(EquationBinaryOperationBase operation) =>
 operation.Type == OperationsEnum.Addition &&
 operation.Left is EquationBinaryOperationBase leftOperation &&