BigReal 1.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package BigReal --version 1.3.0                
NuGet\Install-Package BigReal -Version 1.3.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="1.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BigReal --version 1.3.0                
#r "nuget: BigReal, 1.3.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.
// Install BigReal as a Cake Addin
#addin nuget:?package=BigReal&version=1.3.0

// Install BigReal as a Cake Tool
#tool nuget:?package=BigReal&version=1.3.0                

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.56

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.50636564110975879365

Performance

Basic operations comparing BigReal, BigDecimal, and BigFloat:

  • Add: 10 + 3
  • Divide: 10 / 3
  • DivideToString: (10 / 3).ToString()
Method Mean Error StdDev Gen0 Allocated
Add_BigReal 22.792 ns 0.0487 ns 0.0432 ns - -
Add_BigDecimal 216.776 ns 0.8178 ns 0.7650 ns 0.0153 48 B
Add_BigFloat 23.473 ns 0.0593 ns 0.0554 ns - -
Divide_BigReal 7.759 ns 0.0333 ns 0.0296 ns - -
Divide_BigDecimal 27,114.541 ns 248.3895 ns 232.3437 ns 7.0190 22016 B
Divide_BigFloat 15.682 ns 0.0475 ns 0.0445 ns - -
DivideToString_BigReal 17,448.714 ns 78.7370 ns 73.6507 ns 1.6785 5272 B
DivideToString_BigDecimal 27,533.222 ns 128.9970 ns 114.3525 ns 7.1716 22520 B
DivideToString_BigFloat 18,121.263 ns 65.5024 ns 61.2710 ns 3.0212 9544 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 based on BigFloat by FaustVX. Significant changes were made by Joyless.

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. 
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 BigReal:

Package Downloads
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
1.4.0 57 3/2/2025
1.3.0 70 3/1/2025
1.2.0 55 3/1/2025
1.1.0 56 3/1/2025
1.0.0 53 3/1/2025