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" />
<PackageReference Include="Pure.Primitives.Number.Operations" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=Pure.Primitives.Number.Operations&version=1.6.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Pure.Primitives.Number.Operations
Composable number operations for the Pure ecosystem — arithmetic and comparison value objects over any INumber<T>.
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/.BoolValueaccess; no state is cached internally. - Composable — every operation result is itself an
INumber<T>orIBool, so operations nest freely. - Overflow-safe —
CheckForOverflowUnderflow=true; arithmetic that overflows throwsOverflowException. - AOT-compatible —
IsAotCompatible=true; all types work with Native AOT.
Dependencies
Pure.Primitives.Abstractions— base primitive interfaces (INumber<T>,IBool)
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 | Versions 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.
-
net10.0
- Pure.Primitives.Abstractions (>= 4.4.0)
-
net11.0
- Pure.Primitives.Abstractions (>= 4.4.0)
-
net7.0
- Pure.Primitives.Abstractions (>= 4.4.0)
-
net8.0
- Pure.Primitives.Abstractions (>= 4.4.0)
-
net9.0
- Pure.Primitives.Abstractions (>= 4.4.0)
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.