Skip to content

The app parses math expressions and calculates results.

Notifications You must be signed in to change notification settings

Bundas/calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Burda calculator v1.0

The app parses math expressions and calculates results. It's easy to extend. Just create new operator which implements either IBinaryOperator or IUnaryOperator interface located in Calculator.Operators.Interfaces.

Example binary operator:

public sealed class AddOperator : IBinaryOperator
{
    public int Precedence { get; set; }
    public OperatorAssociativity OperatorAssociativity { get; set; }
    public string OperatorNotationInput { get; set; }
    public string OperatorNotationOutput { get; set; }

    public decimal Calculate(decimal operand1, decimal operand2)
    {
        return operand1 + operand2;
    }

    public AddOperator()
    {
        Precedence = 4;
        OperatorNotationOutput = OperatorNotationInput = "+";
        OperatorAssociativity = OperatorAssociativity.Left;
    }
}

Example unary operator:

public sealed class DecadicLogarithmOperator : IUnaryOperator
{
    public int Precedence { get; set; }
    public OperatorAssociativity OperatorAssociativity { get; set; }
    public string OperatorNotationInput { get; set; }
    public string OperatorNotationOutput { get; set; }
    public UnaryOperatorType UnaryOperatorType { get; set; }
    public decimal Calculate(decimal operand)
    {
        return (decimal) Math.Log10((double) operand);
    }

    public DecadicLogarithmOperator()
    {
        Precedence = 64;
        OperatorNotationOutput = OperatorNotationInput = "log10";
        UnaryOperatorType = UnaryOperatorType.Function;
        OperatorAssociativity = OperatorAssociativity.Left;
    }
}

About

The app parses math expressions and calculates results.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages