Pure.Primitives.Number.Operations 1.6.0

dotnet add package Pure.Primitives.Number.Operations --version 1.6.0
                    
NuGet\Install-Package Pure.Primitives.Number.Operations -Version 1.6.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="Pure.Primitives.Number.Operations" Version="1.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pure.Primitives.Number.Operations" Version="1.6.0" />
                    
Directory.Packages.props
<PackageReference Include="Pure.Primitives.Number.Operations" />
                    
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 Pure.Primitives.Number.Operations --version 1.6.0
                    
#r "nuget: Pure.Primitives.Number.Operations, 1.6.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 Pure.Primitives.Number.Operations@1.6.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=Pure.Primitives.Number.Operations&version=1.6.0
                    
Install as a Cake Addin
#tool nuget:?package=Pure.Primitives.Number.Operations&version=1.6.0
                    
Install as a Cake Tool

Pure.Primitives.Number.Operations

Composable number operations for the Pure ecosystem — arithmetic and comparison value objects over any INumber<T>.

.NET build & test Build and Deploy NuGet License: MIT

Overview

Pure.Primitives.Number.Operations provides sealed record types that implement arithmetic and comparison operations over INumber<T> values. Each type is a lazy, composable value object — the operation is only evaluated when .NumberValue or .BoolValue is accessed.

Operations

Arithmetic (INumber<T>)

Type Constraint Description
Sum<T> INumber<T> Sum of one or more numbers
Difference<T> INumber<T> Sequential subtraction of a sequence of numbers
Product<T> INumber<T> Product of one or more numbers
Quotient<T> IFloatingPoint<T> Sequential division of a sequence of numbers
Remainder<T> INumber<T> Sequential modulo of a sequence of numbers
Abs<T> INumber<T> Absolute value
IncrementedNumber<T> INumber<T> Number incremented by one
DecrementedNumber<T> INumber<T> Number decremented by one
Max<T> INumber<T> Maximum of one or more numbers
Min<T> INumber<T> Minimum of one or more numbers
RoundedNumber<T> IFloatingPoint<T> Rounded value

Comparisons (IBool)

Type Description
EqualCondition<T> True when all numbers are equal
NotEqualCondition<T> True when at least two numbers differ
LessThanCondition<T> True when values are strictly ascending (each < next)
LessThanOrEqualCondition<T> True when values are non-decreasing (each ≤ next)
GreaterThanCondition<T> True when values are strictly descending (each > next)
GreaterThanOrEqualCondition<T> True when values are non-increasing (each ≥ next)
IsNonNegativeCondition<T> True when the value is greater than or equal to T.Zero

Design Principles

  • Lazy — values are computed on every .NumberValue / .BoolValue access; no state is cached internally.
  • Composable — every operation result is itself an INumber<T> or IBool, so operations nest freely.
  • Overflow-safe — CheckForOverflowUnderflow=true; arithmetic that overflows throws OverflowException.
  • AOT-compatible — IsAotCompatible=true; all types work with Native AOT.

Dependencies

Target Frameworks

  • .NET 7
  • .NET 8
  • .NET 9
  • .NET 10
  • .NET 11

Installation

dotnet add package Pure.Primitives.Number.Operations

Usage

using Pure.Primitives.Abstractions.Bool;
using Pure.Primitives.Abstractions.Number;
using Pure.Primitives.Number.Operations;

// Any INumber<T> implementation works — here using a minimal inline one
sealed class N<T>(T v) : INumber<T> where T : System.Numerics.INumber<T>
{
    public T NumberValue => v;
}

INumber<int> a = new N<int>(10);
INumber<int> b = new N<int>(3);

int sum     = new Sum<int>(a, b).NumberValue;         // 13
int diff    = new Difference<int>(a, b).NumberValue;  // 7
int product = new Product<int>(a, b).NumberValue;     // 30

// Operations compose — abs of (b - a)
int absResult = new Abs<int>(new Difference<int>(b, a)).NumberValue; // 7

// Comparison (IBool is an explicit interface)
bool isGreater = ((IBool)new GreaterThanCondition<int>(a, b)).BoolValue; // true
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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 is compatible.  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 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 is compatible.  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.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Pure.Primitives.Number.Operations:

Package Downloads
Pure.Authorization.OpenFGA.Model.Conditions

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.6.0 132 11/11/2026
1.5.0 488 9/8/2026
1.4.0 322 6/17/2026
1.3.0 463 11/22/2025
1.2.0 405 11/1/2025
1.1.0 200 11/1/2025
1.0.2 335 6/13/2025
1.0.1 230 6/7/2025
1.0.0 272 5/27/2025
0.2.1 255 5/26/2025
0.2.0 248 5/25/2025
0.1.0 193 5/23/2025