Skip to content

Commit 9be32b5

Browse files
authored
Merge pull request #87 from IsaMorphic/feature/docs-update-readme
Docs: update README to add documentation and guidelines
2 parents e443bca + 84848cf commit 9be32b5

1 file changed

Lines changed: 64 additions & 3 deletions

File tree

README.md

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
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.
77

8-
### Project TODOs (Completed)
8+
# Main Features
99

1010
- [x] Adheres to recommended requirements of IEEE 754 specification
1111
- [x] Implements .NET 8 `IBinaryFloatingPointIeee754` generic arithmetic interface
@@ -14,7 +14,68 @@ QuadrupleLib is a modern implementation of the IEEE 754 `binary128` floating poi
1414
- [x] Supports all recommended rounding modes for arithmetic
1515
- [x] Implements basic `ToString` and `Parse`/`TryParse` methods
1616
- [x] Supports .NET Core formatting features for `ToString` and `Parse`
17-
- [x] Implements conversion methods to & from all standard number types
17+
- [x] Implements conversion methods to & from all standard number types (except `decimal`)
1818
- [x] Implements `IEEERemainder` as suggested in IEEE 754
1919
- [x] Implements typical library functions (`Pow`, `Atan2`, `Log`)
20-
- [x] Unit tests to check for specification coverage
20+
- [x] Unit tests to check for specification coverage & overall correctness
21+
22+
# Using QuadrupleLib
23+
24+
QuadrupleLib is available as a regularly updated [NuGet package](https://www.nuget.org/packages/QuadrupleLib), published via my GitHub Actions workflow. Alternatively, see the [Releases](https://github.com/IsaMorphic/QuadrupleLib/releases) page for a downloadable version you may use in your local or private feeds.
25+
26+
## Basic Usage
27+
28+
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:
29+
30+
```csharp
31+
global using Float128 = QuadrupleLib.Float128<QuadrupleLib.Accelerators.DefaultAccelerator>;
32+
```
33+
34+
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.
35+
36+
## Defining `Float128` Constants
37+
38+
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:
39+
40+
```csharp
41+
private const string PI = "3.1415926535897932384626433832795028";
42+
43+
private static readonly Float128 _pi = Float128.Parse(PI);
44+
public static Float128 Pi => _pi;
45+
```
46+
47+
## Notes on Hardware Acceleration
48+
49+
`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](https://ilgpu.net), a JIT compiler for running .NET code on the GPU.
50+
51+
# Development Guide
52+
53+
Interested in tinkering with the source code? Feel free to fork this repo and/or clone it as a submodule in your project:
54+
55+
```bash
56+
git submodule add "https://github.com/IsaMorphic/QuadrupleLib.git" "external/QuadrupleLib"
57+
git commit -m "Feature: add QuadrupleLib as submodule"
58+
cd external/QuadrupleLib
59+
```
60+
61+
Then, to build the source code, make sure the .NET 10 SDK is installed on your machine, and run:
62+
63+
```bash
64+
dotnet build --no-incremental
65+
```
66+
67+
Next, to run unit tests, use the following command:
68+
69+
```bash
70+
dotnet test --no-build
71+
```
72+
73+
To build the NuGet package, use the following command:
74+
75+
```bash
76+
dotnet pack --no-build --output build/
77+
```
78+
79+
# Contributing
80+
81+
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.

0 commit comments

Comments
 (0)