The Xamarin.Forms RPN (Reverse Polish Notation) calculator running in WebAssembly
Перейти к файлу
Jérôme Laban fb21032b7e
Merge pull request #65 from unoplatform/dependabot/add-v2-config-file
Upgrade to GitHub-native Dependabot
2021-04-29 20:27:21 -04:00
.github Upgrade to GitHub-native Dependabot 2021-04-29 20:31:52 +00:00
RpnCalculator chore: Update to latest uno stable 2020-06-30 08:12:22 -04:00
Screenshots Initial sources. 2019-09-06 09:53:55 -04:00
.gitignore Initial sources. 2019-09-06 09:53:55 -04:00
.vsts-ci.yml Adjust windows and linux versions 2019-09-09 13:12:29 -04:00
.vsts-linux-build.yml Adjust wasm path 2019-09-09 13:31:10 -04:00
.vsts-win-build.yml Adjust paths 2019-09-09 13:41:48 -04:00
LICENSE Initial sources. 2019-09-06 09:53:55 -04:00
README.md Initial sources. 2019-09-06 09:53:55 -04:00
RpnCalculator.sln chore: Update to latest uno stable 2020-06-30 08:12:22 -04:00
gitversion.yml Initial sources. 2019-09-06 09:53:55 -04:00
nuget.config Uno, X.F updates 2019-10-21 21:18:51 -04:00

README.md

name description page_type languages products urlFragment
Xamarin.Forms - RPN Calculator An RPN (Reverse Polish Notation) calculator allows numbers and operations to be entered without parentheses or an equal key. RPN (also called... sample
csharp
xamarin
rpncalculator

RPN Calculator

An RPN (Reverse Polish Notation) calculator allows numbers and operations to be entered without parentheses or an equal key. RPN (also called postfix notation) is described in the Wikipedia article Reverse Polish notation and the RPN Calculator workbook, which shows an alternative approach to coding an RPN calculator for Xamarin.Forms.

RPN is based on a stack. Numbers are pushed on the stack by pressing the ENTER key. Unary operations (such as log and sin) pop a number from the stack, apply the operation, and push the result back on the stack. Binary operations (such as + and /) pop two numbers from the stack, perform the operation, and push the result on the stack.

To perform the calculation

5 × (3 + 4) – 2

press the following keys:

5 ENTER 3 ENTER 4 ENTER + × 2 ENTER –

The + operation adds 3 and 4, the times operation multiplies 5 and that result, and the minus operation subtracts 2 from that result.

The layout of the keys appears twice in the MainPage.xaml file, separately for portrait mode and landscape mode. The MainPage.xaml.cs code-behind file switches between these two layouts based on the relative width and height of the page.

The calculator logic is encapsulated in the RpnCalculatorViewModel.cs file. The XAML file and the ViewModel are linked through XAML-based data bindings, which are described in detail in the series of series of articles on Data Binding, and particularly the The Command Interface article.

RPN Calculator application screenshot

Author

Charles Petzold