Cross-platform decimal calculator with WPF (Windows) and Avalonia (macOS/Linux) interfaces. Supports basic math operations, decimals, and batch file processing.
Quick fix in Terminal:
xattr -cr ~/Downloads/CalculatorWPF.appDownload the appropriate ZIP file for your system:
- Windows x64: Most modern Windows PCs
- Windows ARM64: ARM-based Windows devices (Surface Pro X, etc.)
Extract and run CalculatorWPF.exe
- Basic operations: +, -, *, /
- Decimal number support: 3.14, 0.5, .25
- Power/exponentiation: ^
- Parentheses for grouping: ( )
- Proper operator precedence using RPN (Reverse Polish Notation)
- Parentheses (highest)
- Exponentiation (^) - right associative
- Multiplication and Division
- Addition and Subtraction (lowest)
- Negative numbers and negative exponents
- Decimal precision (28-29 digits)
- Batch file processing
- Async file operations
- .NET 10 SDK
- Windows (WPF requires Windows)
dotnet builddotnet run --project CalculatorWPF/CalculatorWPF.csprojOr open in Visual Studio and press F5.
dotnet testEnter an expression and click Calculate or press Enter.
Examples:
2 + 3 * 2= 8(2 + 3) * 2= 102 ^ 3= 82 ^ 3 ^ 2= 512 (right associative: 2^(3^2))(2 + 3) ^ 2= 2510 - 5= 5-3 * 4= -12((2 + 3) * 4) ^ 2 - 10= 390
- Select input file (one expression per line)
- Choose output file path
- Click Process File
Input file example:
2 + 3 * 2
(2 + 3) * 2
2 ^ 3
10 - 5
-3 * 4
Output file:
8
10
8
5
-12
- Division by zero:
Error - Division by zero - Invalid characters:
Error - Invalid character: 'x' - Decimals not supported:
Error - Decimal numbers are not supported - Empty expression:
Error - Expression cannot be empty - Mismatched parentheses:
Error - Mismatched parentheses: unclosed opening parenthesis - Negative exponents:
Error - Negative exponents are not supported
CalculatorWPF/
├── CalculatorWPF/
│ ├── Models/
│ │ └── Token.cs
│ ├── Services/
│ │ ├── Tokenizer.cs
│ │ ├── RpnConverter.cs
│ │ ├── ExpressionEvaluator.cs
│ │ ├── CalculatorEngine.cs
│ │ └── FileProcessor.cs
│ └── MainWindow.xaml
└── CalculatorWPF.Tests/
└── Services/
├── TokenizerTests.cs
├── RpnConverterTests.cs
├── ExpressionEvaluatorTests.cs
├── ParenthesesTests.cs
├── ParenthesesValidationTests.cs
├── PowerOperatorTests.cs
├── ComplexExpressionTests.cs
└── (other test files)
The calculator uses Reverse Polish Notation (RPN) with the Shunting Yard algorithm for proper order of operations:
- Tokenizer: Converts input string into tokens (numbers, operators, parentheses)
- RpnConverter: Converts infix notation to RPN using Shunting Yard algorithm
- ExpressionEvaluator: Evaluates RPN expression using a stack-based approach
This approach ensures:
- Correct operator precedence
- Proper handling of parentheses
- Right-associativity for exponentiation
- Efficient evaluation