private static EquationTermBase ProcessDivision(EquationBinaryOperationBase operation) { if (operation.Right.IsZero()) { throw new DevideByZeroInProcessingException(); } return CreateZero(); }
private static EquationTermBase ProcessExponentiation(EquationBinaryOperationBase operation) { if (operation.Left.IsZero() && operation.Right.IsZero()) { throw new AttemptToCalculateZeroAtZeroDegreeException(); } return operation.Left.IsZero() ? CreateZero() : CreateOne(); }
private static EquationTermBase ProcessSubtraction(EquationBinaryOperationBase operation) { if (operation.Right.IsZero()) { return operation.Left; } return new MultiplicationOperation( left: new EquationConstant(decimal.MinusOne), right: operation.Right ); }
// ReSharper disable once UnusedParameter.Local private static EquationTermBase ProcessMultiplication(EquationBinaryOperationBase operation) => CreateZero();
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 &&
private static decimal Right(EquationBinaryOperationBase operation) => Value(operation.Right);
private static decimal Left(EquationBinaryOperationBase operation) => Value(operation.Left);
private static bool MatchShiftRight(EquationBinaryOperationBase operation) => operation.Type == OperationsEnum.Addition && operation.Left is EquationBinaryOperationBase leftOperation &&