Tavenem.HugeNumber 2.5.4

Prefix Reserved
dotnet add package Tavenem.HugeNumber --version 2.5.4                
NuGet\Install-Package Tavenem.HugeNumber -Version 2.5.4                
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="Tavenem.HugeNumber" Version="2.5.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tavenem.HugeNumber --version 2.5.4                
#r "nuget: Tavenem.HugeNumber, 2.5.4"                
#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.
// Install Tavenem.HugeNumber as a Cake Addin
#addin nuget:?package=Tavenem.HugeNumber&version=2.5.4

// Install Tavenem.HugeNumber as a Cake Tool
#tool nuget:?package=Tavenem.HugeNumber&version=2.5.4                

build NuGet downloads

Tavenem.HugeNumber

Tavenem.HugeNumber provides a struct which allows efficient recording of values in the range �999999999999999999x10<sup>�32767</sup>. Also allows representing positive or negative infinity, and NaN (not-a-number).

Note: the parameterless constructor returns NaN (not zero, as might be expected). To obtain zero, use the static propety Zero.

Rational Fractions

Rational fractions cannot be constructed directly. All constructors accept a mantissa, or a mantissa and an exponent. Conversions from floating point types always result in a floating point value. Even an apparently simple value such as 1.5 is assumed to be irrational, since the binary representation of decimal values can often be irrational, and therefore no assumptions are made.

In order to represent a rational fraction with a HugeNumber, first construct (or cast) an integral value as a HugeNumber, then perform a division operation with another integral value. Mathematical operations between two rational fractions, or between a rational fraction and an integral value, will also result in another rational fraction (unless the result is too large). For example: new HugeNumber(2) / 3 will result in the rational fraction 2/3 (i.e. not an approximation such as 0.6666...).

Rational fractions can have a denominator no larger than ushort.MaxValue. Smaller fractional values are represented as a mantissa and negative exponent (with a denominator of 1).

Rational fractions may also have exponents (positive or negative). The smallest HugeNumber greater than zero (Epsilon) is therefore (1/65535)e-32767.

Precision

Values have at most 18 significant digits in the mantissa, and 5 in the exponent. These limits are fixed independently of one another; they do not trade off, as with the standard floating-point types. I.e. you cannot have only one significent digit in the mantissa and thereby gain 22 in the exponent.

Despite the ability to record floating-point values, HugeNumber values are internally stored as an integral mantissa, exponent, and denominator. Therefore, arithmatic operations between HugeNumber values which represent integers or rational fractions are not subject to floating point errors. For example, new HugeNumber(5) * 2 / 2 == 5 is always true.

This also applies to rational fractions: new HugeNumber(10) / 4 == new Number (100) / 40 is also guaranteed to be true.

It also applies to rational floating point values too large to be represented as fractions: new HugeNumber(1, -20) / 4 == new Number (1, -19) / 40 is also guaranteed to be true.

Note that floating point errors are still possible when performing arithmatic operations or comparisons between irrational floating point values, or fractional values too large or small, or with too many significant digits, to be represented as rational fractions. For example, new HugeNumber(2).Sqrt().Square() == 2 is not guaranteed to be true. It may evaluate to true, but this is not guaranteed. The usual caveats and safeguards typically employed when performing floating point math and/or comparisons should be applied to HugeNumber instances which do not represent integral values or rational fractions. The method IsNotRational(HugeNumber) can be used to determine whether a number is not integral or a rational fraction, in order to determine if such safeguards are required.

Installation

Tavenem.HugeNumber is available as a NuGet package.

Roadmap

Tavenem.HugeNumber is a relatively stable library. Although additions and bugfixes are possible at any time, release should generally be expected to folow the .NET release cycle, with one or more preview releases during a framework preview, and a new stable release coinciding with the release of a new .NET framework major version.

Contributing

Contributions are always welcome. Please carefully read the contributing document to learn more before submitting issues or pull requests.

Code of conduct

Please read the code of conduct before engaging with our community, including but not limited to submitting or replying to an issue or pull request.

Product Compatible and additional computed target framework versions.
.NET 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. 
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 Tavenem.HugeNumber:

Package Downloads
Tavenem.Universe

Classes to help model a universe.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.5.4 209 3/1/2024
2.4.5 141 3/1/2024
2.3.4 200 11/24/2023
2.2.6 323 7/21/2023
2.1.3 371 11/8/2022
2.1.0-preview.1 112 9/29/2022
2.0.0 334 12/3/2021
2.0.0-preview.7 170 8/30/2021
2.0.0-preview.6 151 8/28/2021
2.0.0-preview.5 147 8/28/2021
2.0.0-preview.4 148 8/26/2021
2.0.0-preview.3 142 8/23/2021
2.0.0-preview.2 162 8/16/2021
2.0.0-preview.1 143 8/16/2021
1.0.2 786 5/3/2021
1.0.1 1,597 4/9/2021
1.0.0 337 4/8/2021