Skip to content

OnixLabs.Numerics

Matthew Layton edited this page Nov 15, 2026 · 5 revisions

OnixLabs.Numerics

View on NuGet

High-precision numeric types and generic math utilities for scenarios where the built-in numeric types are insufficient. This package emphasizes correctness, precision, and introspection of numeric values.

Installation

dotnet add package OnixLabs.Numerics

Features

  • Arbitrary-precision BigDecimal built on generic math (IFloatingPoint<T>).
  • Extended-width integer types (Int256, UInt256, Int512, UInt512).
  • Extended-precision floating-point types (Float128, Float256).
  • NumberInfo for dissecting rational numbers into their constituent parts.
  • Generic math helpers (GenericMath) over the BCL numeric interfaces (INumber<T>, IBinaryInteger<T>).
  • Extension methods for Decimal, BigDecimal, BigInteger, and other numeric types.

API Reference

All types are in the OnixLabs.Numerics namespace.

High-precision numerics

Type Description
BigDecimal Arbitrary-precision decimal built on generic math, with strict and semantic equality.
BigDecimalEqualityComparer Strict/semantic equality comparer for BigDecimal.
BigDecimalOrdinalityComparer Ordinal comparer for BigDecimal.
NumberInfo Dissects a rational number into its constituent parts (unscaled value, scale, significand, exponent, sign, precision).
NumberInfoEqualityComparer Strict/semantic equality comparer for NumberInfo.
NumberInfoOrdinalityComparer Ordinal comparer for NumberInfo.

Extended-width integers

Type Description
Int256 256-bit signed integer with full IBinaryInteger<T> / ISignedNumber<T> generic-math support.
Int512 512-bit signed integer.
UInt256 256-bit unsigned integer (IUnsignedNumber<T>).
UInt512 512-bit unsigned integer.

Extended-precision floating-point

Type Description
Float128 128-bit IEEE-754 binary floating-point (quad precision), IBinaryFloatingPointIeee754<T>.
Float256 256-bit IEEE-754 binary floating-point (octuple precision).

Utilities and enumerations

Type Description
GenericMath Generic mathematical helpers (Delta, Factorial, IntegerLength, MinMax, Pow, Pow10) over INumber<T> / IBinaryInteger<T>.
NumericsExtensions Extension methods converting decimal, BigInteger, and other numeric types to BigDecimal, NumberInfo, and scaled values.
ConversionMode Selects decimal vs binary interpretation when converting IEEE-754 values.
ScaleMode Selects fractional vs integral scaling behaviour.

Requirements

Item Supported
Target frameworks .NET 8.0, .NET 9.0, .NET 10.0, .NET 11.0
Language version C# 15
License Apache-2.0

See Also

ONIXLabs .NET Library


Clone this wiki locally