QuadrupleLib 0.1.6

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

QuadrupleLib

.NET NuGet

QuadrupleLib is a modern implementation of the IEEE 754 binary128 floating point number type for .NET 8 and above based on the UInt128 built-in. The goal of this project is to create a fully fleshed out 128-bit floating point arithmetic library that includes all of the bells and whistles one could possibly want.

Main Features

  • Adheres to recommended requirements of IEEE 754 specification
  • Implements .NET 8 IBinaryFloatingPointIeee754 generic arithmetic interface
  • Implements all basic arithmetic operations (+, -, *, /, %, ++, --)
  • Implements all standard rounding functions (Round, Floor, Ceiling)
  • Supports all recommended rounding modes for arithmetic
  • Implements basic ToString and Parse/TryParse methods
  • Supports .NET Core formatting features for ToString and Parse
  • Implements conversion methods to & from all standard number types (except decimal)
  • Implements IEEERemainder as suggested in IEEE 754
  • Implements typical library functions (Pow, Atan2, Log)
  • Unit tests to check for specification coverage & overall correctness

Using QuadrupleLib

QuadrupleLib is available as a regularly updated NuGet package, published via my GitHub Actions workflow. Alternatively, see the Releases page for a downloadable version you may use in your local or private feeds.

Basic Usage

To use QuadrupleLib in your project, simply add the PackageReference to your .csproj file and add the following using statement to the top of any single file in your project:

global using Float128 = QuadrupleLib.Float128<QuadrupleLib.Accelerators.DefaultAccelerator>;

The Float128 type as defined above includes a full implementation of the .NET 8 IBinaryFloatingPointIeee754<T> generic arithmetic interface. You may use it as thus either generically or concretely. Generally, anywhere you're using double or float arithmetic, you can use Float128 as a drop-in replacement and everything will work as expected.

Defining Float128 Constants

For defining high-precision constants, it is highly recommended that Float128.Parse is used with a given const string. While literal double and long values can be implicitly converted to Float128, you will not be able to specify the maximum amount of significant digits that you would otherwise be able to using the Parse method. See the example below for reference:

private const string PI = "3.1415926535897932384626433832795028";

private static readonly Float128 _pi = Float128.Parse(PI);
public static Float128 Pi => _pi;

Notes on Hardware Acceleration

Float128<TAccelerator> is a generic type offered by the library which can accept one of two "accelerators" that are built-in: DefaultAccelerator and SoftwareAccelerator. The former uses typical hardware accelerated intrinsics for 128-bit multiplication and division operations, while the latter provides a custom, software defined version of the same thing. In almost all cases, you'll want to use DefaultAccelerator, unless you are running your code on a platform that does not include intrinsics for 128-bit arithmetic. In those cases, SoftwareAccelerator provides a faster alternative that is widely compatible. The most notable example of such a platform is when using QuadrupleLib in conjunction with ILGPU, a JIT compiler for running .NET code on the GPU.

Development Guide

Interested in tinkering with the source code? Feel free to fork this repo and/or clone it as a submodule in your project:

git submodule add "https://github.com/IsaMorphic/QuadrupleLib.git" "external/QuadrupleLib"
git commit -m "Feature: add QuadrupleLib as submodule"
cd external/QuadrupleLib

Then, to build the source code, make sure the .NET 10 SDK is installed on your machine, and run:

dotnet build --no-incremental

Next, to run unit tests, use the following command:

dotnet test --no-build

To build the NuGet package, use the following command:

dotnet pack --no-build --output build/

Contributing

Before contributing any changes to the project, make sure that all the standard unit tests are passing. If your changes are a work-in-progress, please mark those PRs as drafts. I will not accept any changes which do not pass all existing unit tests; any new features should include new tests to cover them. Finally, do NOT contribute code written by Copilot or other LLMs. QuadrupleLib is written by humans, for humans.

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.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on QuadrupleLib:

Package Downloads
GoogolSharp

Represents numbers with reasonable precision, and googological range.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.6 156 3/20/2026
0.1.5 80 3/20/2026
0.1.4 83 3/19/2026
0.1.3 82 3/19/2026
0.1.2 110 3/18/2026
0.1.1 83 3/18/2026
0.1.0 214 3/14/2026