High-precision arithmetic class representing numbers with a significand and exponent. Supports significant figure rules, mathematical computations, and formatting.
Repo ktsu-dev/SignificantNumber, read from GitHub 15 min ago. ktsu-dev has not joined Take My Repo.
ktsu-dev/SignificantNumber is a public repo on GitHub by ktsu-dev. High-precision arithmetic class representing numbers with a significand and exponent. Supports significant figure rules, mathematical computations, and formatting. It declares the MIT license on GitHub. It is written mainly in C#, has 1 stars and last changed on 2026-11-16. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-21.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
SignificantNumber is a numeric value type whose arithmetic follows the rules for significant figures. It holds a ktsu.PreciseNumber and rounds every result to the precision its operands justify.
readonly record struct whose default is zero, holding a PreciseNumber that it converts to implicitlyINumber<SignificantNumber>, including CreateChecked, CreateSaturating, and CreateTruncating for every built-in numeric type, BigInteger, and PreciseNumberUpgrading from 1.x? See the 2.0 migration guide.
Every release measures a fixed set of benchmarks and adds a point to the chart; the numbers behind
it are in docs/benchmarks/history.json, and the suite is
SignificantNumber.Benchmarks.
Read the two halves differently. Allocation is exact — the same code allocates the same bytes on any machine, so a step in the top row is always a real change. Time is measured on shared CI runners, where the host a job happens to land on varies more than most releases do, so each time is divided by a reference workload measured in the same job. That cancels most of the difference between machines; what is left is indicative rather than precise.
The step at 2.0 is the type becoming a readonly record struct over PreciseNumber instead of
deriving from it. A 200-digit addition went from 54,688 bytes and 128 μs to 112 bytes and 340 ns.
Install the package with the .NET CLI:
dotnet add package ktsu.SignificantNumber
Or add the package reference directly in your project file:
<PackageReference Include="ktsu.SignificantNumber" Version="x.x.x" />
Create a SignificantNumber from any supported numeric type with the ToSignificantNumber extension method, from text with Parse, or from a PreciseNumber with an explicit cast.
ToSignificantNumber converts through INumber<T>. These types are supported:
Integer types:
intlongshortsbyteuintulongushortbyteBigIntegerFloating point types:
doublefloatHalfdecimalktsu types:
PreciseNumberSignificantNumberusing System.Numerics;
using ktsu.PreciseNumber;
using ktsu.SignificantNumber;
// Integer types
int intValue = 12345;
SignificantNumber significantNumberFromInt = intValue.ToSignificantNumber();
BigInteger bigIntValue = new BigInteger(9876543210);
SignificantNumber significantNumberFromBigInt = bigIntValue.ToSignificantNumber();
// Floating point types
double doubleValue = 123.45;
SignificantNumber significantNumberFromDouble = doubleValue.ToSignificantNumber();
Half halfValue = (Half)123.45;
SignificantNumber significantNumberFromHalf = halfValue.ToSignificantNumber();
float floatValue = 123.45f;
SignificantNumber significantNumberFromFloat = floatValue.ToSignificantNumber();
decimal decimalValue = 123.45m;
SignificantNumber significantNumberFromDecimal = decimalValue.ToSignificantNumber();
// A PreciseNumber, with an explicit cast because it opts into the significant figure rules
PreciseNumber precise = 12.5.ToPreciseNumber();
SignificantNumber significantNumberFromPrecise = (SignificantNumber)precise;
SignificantNumber result1 = number1 + number2;
SignificantNumber result2 = number1 - number2;
SignificantNumber result3 = number1 * number2;
SignificantNumber result4 = number1 / number2;
// Square and cube operations, which return the unrounded PreciseNumber
PreciseNumber squared = number1.Squared();
PreciseNumber cubed = number1.Cubed();
// Power operation
SignificantNumber powerResult = number1.Pow(3.ToPreciseNumber());
The operators also accept a PreciseNumber on either side, and the result is a SignificantNumber.
bool isEqual = number1 == number2;
bool isGreater = number1 > number2;
bool isLessOrEqual = number1 <= number2;
Ordering operators, Equals and CompareTo compare values exactly, so Array.Sort, OrderBy, SortedSet and Comparer<SignificantNumber>.Default all see one consistent order.
To ask whether two measurements agree to the precision they share, use SignificantNumber.CompareAtSignificance(left, right). It compares both numbers at the lower of their significant digit counts, so 1.23 and 1.2 compare equal. That comparison is not transitive (1.2 also equals 1.17, but 1.23 does not), so don't sort with it.
int exact = number1.CompareTo(number2);
int atSharedPrecision = SignificantNumber.CompareAtSignificance(number1, number2);
Format a SignificantNumber as a string:
string formatted = number1.ToString("G", CultureInfo.InvariantCulture);
Console.WriteLine(formatted); // Outputs the formatted number
G, R, F, N and E are written from the exact value, at any magnitude. Other formats, such as C, P or a custom
pattern like #,##0.00, are written the way decimal writes the value, cut to its 28 or 29 significant digits
when needed (so the value is rounded once, at the digits the format shows), and the way double writes it when it is too large or too small for decimal. A value outside
double's finite range, such as 1E400, throws FormatException for those formats rather than printing
Infinity or 0; use E or G for it.
Parse one from text, including scientific notation:
SignificantNumber parsed = SignificantNumber.Parse("1.23E4", NumberStyles.Float, CultureInfo.InvariantCulture);
if (SignificantNumber.TryParse("123.45", CultureInfo.InvariantCulture, out SignificantNumber result))
{
Console.WriteLine(result);
}
TryParse yields zero when parsing fails.
A null format provider, and ToString() with none, mean the current culture for every format and for
Parse/TryParse, as they do for decimal. Pass CultureInfo.InvariantCulture for culture-independent text.
ToSignificantNumberConverts a supported numeric type to a SignificantNumber. An overload takes the number of significant digits to keep.
public static SignificantNumber ToSignificantNumber<TInput>(this TInput input)
where TInput : INumber<TInput>
public static SignificantNumber ToSignificantNumber<TInput>(this TInput input, int significantDigits)
where TInput : INumber<TInput>
input: The number to convert.significantDigits: The number of significant digits to keep. It must be greater than zero.SignificantNumber: The converted number.double floatingPointValue = 123.45;
SignificantNumber significantNumberFromFloat = floatingPointValue.ToSignificantNumber();
int integerValue = 12345;
SignificantNumber significantNumberFromInt = integerValue.ToSignificantNumber();
SignificantNumber result = significantNumberFromFloat + significantNumberFromInt;
// result = 12468.45
To<TOutput>Converts a SignificantNumber to the specified numeric type.
public TOutput To<TOutput>()
where TOutput : INumber<TOutput>
TOutput: The converted value of the SignificantNumber.SignificantNumber significantNumber = SignificantNumber.Parse("12345E3", NumberStyles.Float, CultureInfo.InvariantCulture);
double result = significantNumber.To<double>();
Console.WriteLine(result); // Outputs 12345000
Generic code converts the same way through CreateChecked, CreateSaturating, and CreateTruncating:
static T ToMeters<T>(T feet) where T : INumber<T> => feet * T.CreateChecked(0.3048);
SignificantNumber meters = ToMeters(10.ToSignificantNumber());
double asDouble = double.CreateChecked(meters);
A SignificantNumber converts to a PreciseNumber implicitly, and Value returns the PreciseNumber it holds.
A SignificantNumber holds a PreciseNumber, which stores two components:
BigInteger.Significand, Exponent, and SignificantDigits are available directly on SignificantNumber.
float keeps up to 8 significant digits, and a double up to 16.Round rounds to a number of decimal digits, and ReduceSignificance to a number of significant digits.Consider the number 123.456000:
SignificantNumber, it's stored as 123456e-3 after removing the trailing zeros and adjusting the exponent.1.2 to it rounds the sum to one decimal place, giving 124.7, because 1.2 has the fewest decimal places.PreciseNumber Value - Gets the PreciseNumber the number holds.int Exponent, BigInteger Significand, and int SignificantDigits - Get the components of the held value.static SignificantNumber NegativeOne, One, and Zero - Get -1, 1, and 0. Zero is also default.static SignificantNumber E, Pi, and Tau - Get the mathematical constants.static int Radix - Gets the radix, or base, for the type.static SignificantNumber AdditiveIdentity - Gets the additive identity of the type.static SignificantNumber MultiplicativeIdentity - Gets the multiplicative identity of the type.bool Equals(SignificantNumber other) - Determines whether two numbers have the same significand and exponent.int CompareTo(object? obj) - Compares the current instance with another object.int CompareTo(SignificantNumber other) - Compares the value of the current instance with another significant number exactly.int CompareTo<TInput>(TInput other) where TInput : INumber<TInput> - Compares the value of the current instance with another number.PreciseNumber Abs() - Returns the absolute value of the current instance.PreciseNumber Round(int decimalDigits) - Rounds the current instance to the specified number of decimal digits.PreciseNumber ReduceSignificance(int significantDigits) - Reduces the current instance to the specified number of significant digits.PreciseNumber Clamp<TNumber>(TNumber min, TNumber max) where TNumber : INumber<TNumber> - Clamps the current instance between the minimum and maximum values.SignificantNumber Pow(PreciseNumber power) - Raises the current instance to a power.PreciseNumber ToPreciseNumber() - Returns the PreciseNumber the number holds.string ToString(string? format, IFormatProvider? formatProvider) - Converts the current instance to a string using the specified format and format provider.bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider) - Attempts to format the current instance into the provided span.TOutput To<TOutput>() where TOutput : INumber<TOutput> - Converts the current significant number to the specified numeric type.static SignificantNumber FromPreciseNumber(PreciseNumber value) - Creates a significant number that holds a PreciseNumber.static SignificantNumber Add, Subtract, Multiply, Divide, and Mod(PreciseNumber left, PreciseNumber right) - Apply the significant figure rules to two numbers.static SignificantNumber Exp(PreciseNumber power) - Raises e to a power.static SignificantNumber Max, Min(SignificantNumber x, SignificantNumber y), and Clamp(SignificantNumber value, SignificantNumber min, SignificantNumber max) - Compare by value.static int CompareAtSignificance(PreciseNumber left, PreciseNumber right) - Compares two numbers at the lower of their significant digit counts. Not a total order, so not for sorting.static SignificantNumber Round(SignificantNumber value, int decimalDigits) - Rounds a number to the specified number of decimal digits.static SignificantNumber Abs(SignificantNumber value) - Returns the absolute value of a SignificantNumber.static bool IsCanonical(SignificantNumber value) - Determines whether the specified value is canonical.static bool IsComplexNumber(SignificantNumber value) - Determines whether the specified value is a complex number.static bool IsEvenInteger(SignificantNumber value) - Determines whether the specified value is an even integer.static bool IsFinite(SignificantNumber value) - Determines whether the specified value is finite.static bool IsImaginaryNumber(SignificantNumber value) - Determines whether the specified value is an imaginary number.static bool IsInfinity(SignificantNumber value) - Determines whether the specified value is infinite.static bool IsInteger(SignificantNumber value) - Determines whether the specified value is an integer.static bool IsNaN(SignificantNumber value) - Determines whether the specified value is NaN.static bool IsNegative(SignificantNumber value) - Determines whether the specified value is negative.static bool IsNegativeInfinity(SignificantNumber value) - Determines whether the specified value is negative infinity.static bool IsNormal(SignificantNumber value) - Determines whether the specified value is normal.static bool IsOddInteger(SignificantNumber value) - Determines whether the specified value is an odd integer.static bool IsPositive(SignificantNumber value) - Determines whether the specified value is positive.static bool IsPositiveInfinity(SignificantNumber value) - Determines whether the specified value is positive infinity.static bool IsRealNumber(SignificantNumber value) - Determines whether the specified value is a real number.static bool IsSubnormal(SignificantNumber value) - Determines whether the specified value is subnormal.static bool IsZero(SignificantNumber value) - Determines whether the specified value is zero.static SignificantNumber MaxMagnitude(SignificantNumber x, SignificantNumber y) - Returns the larger of the magnitudes of two significant numbers.static SignificantNumber MaxMagnitudeNumber(SignificantNumber x, SignificantNumber y) - Returns the larger of the magnitudes of two significant numbers.static SignificantNumber MinMagnitude(SignificantNumber x, SignificantNumber y) - Returns the smaller of the magnitudes of two significant numbers.static SignificantNumber MinMagnitudeNumber(SignificantNumber x, SignificantNumber y) - Returns the smaller of the magnitudes of two significant numbers.static implicit operator PreciseNumber(SignificantNumber value) - Converts to the held PreciseNumber.static explicit operator SignificantNumber(PreciseNumber value) - Creates a significant number that holds a PreciseNumber.static SignificantNumber operator -(SignificantNumber value) - Negates a significant number.static SignificantNumber operator +, -, *, /, and % - Apply the significant figure rules. Each also accepts a PreciseNumber on either side.static SignificantNumber operator +(SignificantNumber value) - Returns the unary plus of a significant number.static SignificantNumber operator ++ and -- - Increment and decrement by one.static bool operator == and != - Determine whether two numbers are equal, including against a PreciseNumber.static bool operator >, <, >=, and <= - Compare two numbers, including against a PreciseNumber.Contributions are welcome. Submit a pull request or open an issue.
This project is licensed under the MIT License. See the LICENSE file for details.
ktsu-dev/SignificantNumber is a public repo on GitHub by ktsu-dev. High-precision arithmetic class representing numbers with a significand and exponent. Supports significant figure rules, mathematical computations, and formatting.
It declares the MIT license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2026-11-16. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
Algorithms and functions for fast exponentiation with small error
freeCodeCamp.org's open-source codebase and curriculum. Learn math, programming, and computer science for free.
A modern file manager that helps users organize their files and folders.
Quantum chatting app UI with React Native with Expo

A community-maintained Python framework for creating mathematical animations.

A comprehensive .NET library suite for building desktop applications with Dear ImGui.
A cross-platform credential cache for .NET that keeps secrets in memory for fast process-lifetime lookup and persists each one through the host's native keyring: Windows Credential Manager, macOS Keychain Services, or the freedesktop.org Secret Service on Linux.
A modern, extensible Text User Interface (TUI) library for .NET that provides rich terminal UI components built on Spectre.Console. Create interactive console applications with styled text, borders, layouts, and keyboard input handling using clean, object-oriented APIs.
A .NET command-line tool that uses a local Ollama vision model to generate descriptions and suggested filenames for images in bulk.

A flexible and extensible .NET library for representing code as language-agnostic Abstract Syntax Trees, serializing them to human-readable YAML for round-trip storage and version control, and generating source code in multiple target languages.
A .NET library for persistent application data storage using JSON serialization. Provides a simple inherit-and-use pattern with automatic file management, thread-safe operations, debounced saves, backup recovery, and singleton access. Stores data in the user's app data folder with support for custom subdirectories and file names.