BigReal 5.1.0

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

BigReal

NuGet

An arbitrary size and precision rational number stored using two BigIntegers.

Usage

Create from fixed-size numbers:

Console.WriteLine(new BigReal(100)); // 100
Console.WriteLine((BigReal)3.14); // 3.14
Console.WriteLine(new BigReal(4, 3).ToString(4)); // 1.3333

Perform basic operations:

Console.WriteLine((BigReal)3 * (BigReal)5); // 15
Console.WriteLine(BigReal.Pow(3.4, 2)); // 11.559999999999999

Parse from string:

Console.WriteLine(BigReal.Parse("12.34")); // 12.34
Console.WriteLine(BigReal.Parse("2e2.5").ToString(2)); // 632.45

Trigonometry:

Console.WriteLine(BigReal.Sin(100).ToString(20)); // -0.5063656411097587906

Performance

Basic operations comparing BigReal, BigDecimal, and BigFloat:

  • Add: 10 + 3
  • Divide: 10 / 3
  • DivideToString: (10 / 3).ToString()
  • Parse: Parse("12345.6789")
  • FromFloat: 123.45f
Method Mean Error StdDev Gen0 Allocated
Add_BigReal 20.663 ns 0.2319 ns 0.2056 ns - -
Add_BigDecimal 196.293 ns 0.7841 ns 0.6951 ns 0.0076 48 B
Add_BigFloat 21.373 ns 0.1374 ns 0.1148 ns - -
Divide_BigReal 7.021 ns 0.0463 ns 0.0433 ns - -
Divide_BigDecimal 23,632.775 ns 76.0503 ns 63.5055 ns 3.5095 22016 B
Divide_BigFloat 14.317 ns 0.0283 ns 0.0251 ns - -
DivideToString_BigReal 1,190.507 ns 4.9752 ns 4.4103 ns 0.0629 400 B
DivideToString_BigDecimal 24,023.287 ns 181.1982 ns 169.4929 ns 3.5706 22520 B
DivideToString_BigFloat 16,281.624 ns 72.3191 ns 67.6473 ns 1.4954 9544 B
Parse_BigReal 283.959 ns 1.5225 ns 1.3497 ns 0.0062 40 B
Parse_BigDecimal 185.566 ns 0.5260 ns 0.4392 ns 0.0126 80 B
Parse_BigFloat 304.154 ns 0.9946 ns 0.7765 ns 0.0062 40 B
FromFloat_BigReal 106.022 ns 0.5105 ns 0.4775 ns - -
FromFloat_BigDecimal 275.546 ns 0.7714 ns 0.6441 ns 0.0162 104 B
FromFloat_BigFloat 1,663.926 ns 8.3387 ns 7.8000 ns 0.1068 672 B

Notes:

  • Whereas BigDecimal divides by calculating the decimal digits at a certain precision, BigReal stores a fraction so the digits are only calculated at ToString.

Background

BigReal is made by Joyless and based on BigFloat by FaustVX. Some inspiration was taken from BigDecimal by AdamWhiteHat.

Gotchas

  • The default value of BigReal is NaN, since 0 / 0 is NaN.
  • Dividing by 0 gives positive or negative infinity depending on the numerator.
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 was computed.  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.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on BigReal:

Package Downloads
JsonhCs

JSON for Humans.

BigDateTime

An arbitrary size and precision date and time stored using a BigReal.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.1.0 92 8/14/2025
5.0.0 92 8/14/2025
4.3.0 277 7/21/2025
4.2.0 189 6/26/2025
4.1.0 781 3/25/2025
4.0.0 194 3/12/2025
3.0.0 187 3/12/2025
2.0.0 187 3/10/2025
1.4.0 132 3/2/2025
1.3.0 125 3/1/2025
1.2.0 106 3/1/2025
1.1.0 109 3/1/2025
1.0.0 114 3/1/2025