ClassicCalculator 1.0.1

dotnet add package ClassicCalculator --version 1.0.1
                    
NuGet\Install-Package ClassicCalculator -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ClassicCalculator" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ClassicCalculator" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ClassicCalculator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ClassicCalculator --version 1.0.1
                    
#r "nuget: ClassicCalculator, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=ClassicCalculator&version=1.0.1
                    
Install ClassicCalculator as a Cake Addin
#tool nuget:?package=ClassicCalculator&version=1.0.1
                    
Install ClassicCalculator as a Cake Tool

Classic Calculator

A classic calculator engine that responds to pressing buttons and provides output including display value.

Table of Contents

Description

It's a simple library that enables the user to create a calculator application or functionality without implementing any of the internal logic on their own. All they have to provide is a user interface that calls the library in response to user actions (e.g. pressing buttons) and presents the display value.

Features

The following actions/buttons are currently supported:

  • Digits (0-9)
  • Decimal point (.)
  • Toggle sign (+/-)
  • Add (+)
  • Subtract (-)
  • Multiply (*)
  • Divide (/)
  • Calculate/Equals (=)
  • Percent (%)
  • Sqaure root (√)
  • Clear (C)

At the moment the only output is the display value but more details will be returned in the future versions.

When creating the calculator object, the user must provide the display length in the constructor which specifies how many digits can be displayed. This will affect the calculator in the same way as it normally does on the physical devices:

  1. User input is limited to the display length
  2. An error occurs when the integer part of the display value is too large to fit in the display
  3. The least meaningful digits of the decimal part of the display value are truncated to fit in the display

The user can also provide a logger object in the constructor that will be used internally by the library.

Missing functionality:

  • Memory features (M+, M-, etc.)
  • CE (clear last entry)
  • Other features of more advanced calculators

Usage

An example usage:

var calculator = new Calculator(9); // Display can show up to 9 digits (DisplayValue = 0)
calculator.PressButton(CalculatorButton.One) // (DisplayValue = 1)
calculator.PressButton(CalculatorButton.Add) // (DisplayValue = 1)
calculator.PressButton(CalculatorButton.Five) // (DisplayValue = 5)
calculator.PressButton(CalculatorButton.Equals) // (DisplayValue = 6)
var displayValue = calculator.DisplayValue; 

For more details, please refer to the provided documentation.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 92 3/21/2025
1.0.0 150 3/20/2025

Initial version of the library.