Tree3.Calculator 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Tree3.Calculator --version 1.0.0
                    
NuGet\Install-Package Tree3.Calculator -Version 1.0.0
                    
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="Tree3.Calculator" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tree3.Calculator" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Tree3.Calculator" />
                    
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 Tree3.Calculator --version 1.0.0
                    
#r "nuget: Tree3.Calculator, 1.0.0"
                    
#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.
#:package Tree3.Calculator@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Tree3.Calculator&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Tree3.Calculator&version=1.0.0
                    
Install as a Cake Tool

Tree3.Calculator

Tree3.Calculator is a lightweight .NET 9.0 library that provides asynchronous, high-precision non-negative integer arithmetic operations.
It defines a clean abstraction for performing addition, subtraction, multiplication, division, and modulo operations on arbitrarily large non-negative integers represented as strings.


Features

  • Asynchronous API � all operations return Task<string>, ready for use in async workflows.
  • Arbitrary-precision integer support � operands are passed as strings, enabling calculations with values larger than long limits.
  • Simple, extensible interface � easy to implement with any numeric backend (e.g., BigInteger, external calculator service, or distributed computation engine).
  • Consistent method naming � unified API for addition, subtraction, multiplication, division, and modulo.
  • Serialization-friendly � string inputs/outputs integrate seamlessly with JSON APIs and network-based systems.
  • Testable and mockable � ideal for dependency injection and unit testing scenarios.
  • Cross-platform � built for .NET 9.0, works on Windows, Linux, and macOS.

Usage

using Tree3.Converter;

var calculator = new DecimalCalculator();
string sum = await calculator.AddAsync("12345", "1");
// Output: "123456"

string product = await calculator.MultiplyAsync("12345", "1");
// Output: "12345"

string invalid = await calculator.DivideAsync("12345", "-a1");
// Output: "N/A"
using Tree3.Converter;

var calculator = new BinaryCalculator();
string sum = await calculator.AddAsync("10", "1");
// Output: "11"

string product = await calculator.MultiplyAsync("10", "11");
// Output: "110"

string invalid = await calculator.SubtractAsync("11011", "abc");
// Output: "N/A"

Performance

NET 9 / Windows 11 / Intel i5 CPU

  • Addition: adds two decimal integers with 100,000 digits in ~0.9 seconds

  • Subtraction: subtracts two decimal integers with 100,000 digits in ~0.9 seconds

  • Multiplication: multiplies two decimal integers with 100,000 digits in ~2.9 seconds

  • Division: divides two decimal integers with 100,000 / 50,000 digits in ~0.4 seconds

  • Modulo: computes remainder of two decimal integers with 100,000 / 50,000 digits in ~0.4 seconds

  • Addition: adds two binary integers with 100,000 digits in ~2.8 seconds

  • Subtraction: subtracts two binary integers with 100,000 digits in ~1.2 seconds

  • Multiplication: multiplies two binary integers with 100,000 digits in ~5 seconds

  • Division: divides two binary integers with 100,000 / 50,000 digits in ~1.2 seconds

  • Modulo: computes remainder of two binary integers with 100,000 / 50,000 digits in ~1.2 seconds


Release Notes

v1.0.0 � 2025-11-12

Initial release of Tree3.Calculator

  • Added ICalculator interface for asynchronous non-negative integer arithmetic.
  • Supported operations:
    • AddAsync(string firstAddend, string secondAddend)
    • SubtractAsync(string minuend, string subtrahend)
    • MultiplyAsync(string firstFactor, string secondFactor)
    • DivideAsync(string dividend, string divisor)
    • ModAsync(string dividend, string divisor)
  • All methods return results as string values, allowing support for very large numbers.
  • Compatible with .NET 9.0.
  • Designed for extensibility and dependency injection.
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows 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
3.0.0 332 11/30/2025
2.0.0 274 11/16/2025
1.0.0 269 11/12/2025

- Added `ICalculator` interface for asynchronous non-negative integer arithmetic.
     - Supported operations:
     - `AddAsync(string firstAddend, string secondAddend)`
     - `SubtractAsync(string minuend, string subtrahend)`
     - `MultiplyAsync(string firstFactor, string secondFactor)`
     - `DivideAsync(string dividend, string divisor)`
     - `ModAsync(string dividend, string divisor)`
     - All methods return results as `string` values, allowing support for very large numbers.
     - Compatible with .NET 9.0.
     - Designed for extensibility and dependency injection.