BigReal 1.4.0
dotnet add package BigReal --version 1.4.0
NuGet\Install-Package BigReal -Version 1.4.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.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BigReal --version 1.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BigReal, 1.4.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.4.0 // Install BigReal as a Cake Tool #tool nuget:?package=BigReal&version=1.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
BigReal
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()
Parse
:Parse("12345.6789")
FromFloat
:123.45f
Method | Mean | Error | StdDev | Gen0 | Allocated |
---|---|---|---|---|---|
Add_BigReal | 21.691 ns | 0.0874 ns | 0.0818 ns | - | - |
Add_BigDecimal | 214.255 ns | 0.9779 ns | 0.9147 ns | 0.0153 | 48 B |
Add_BigFloat | 23.496 ns | 0.0683 ns | 0.0639 ns | - | - |
Divide_BigReal | 7.670 ns | 0.0221 ns | 0.0207 ns | - | - |
Divide_BigDecimal | 26,478.999 ns | 96.2829 ns | 80.4006 ns | 7.0190 | 22016 B |
Divide_BigFloat | 15.538 ns | 0.0551 ns | 0.0515 ns | - | - |
DivideToString_BigReal | 17,104.758 ns | 84.1202 ns | 78.6861 ns | 1.6785 | 5272 B |
DivideToString_BigDecimal | 26,800.138 ns | 133.3113 ns | 118.1770 ns | 7.1716 | 22520 B |
DivideToString_BigFloat | 17,918.482 ns | 86.7425 ns | 81.1390 ns | 3.0212 | 9544 B |
Parse_BigReal | 295.278 ns | 1.3559 ns | 1.2683 ns | 0.0124 | 40 B |
Parse_BigDecimal | 211.807 ns | 1.1707 ns | 1.0951 ns | 0.0253 | 80 B |
Parse_BigFloat | 335.903 ns | 1.2944 ns | 1.1475 ns | 0.0124 | 40 B |
FromFloat_BigReal | 393.450 ns | 2.1953 ns | 1.9461 ns | 0.0229 | 72 B |
FromFloat_BigDecimal | 316.437 ns | 1.3594 ns | 1.2715 ns | 0.0329 | 104 B |
FromFloat_BigFloat | 1,779.366 ns | 4.8228 ns | 4.5113 ns | 0.2136 | 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 atToString
.
Background
BigReal
is made by Joyless and based on BigFloat
by FaustVX.
Some inspiration was taken from BigDecimal
by AdamWhiteHat.
Gotchas
- The
default
value ofBigReal
is NaN, since 0 / 0 is NaN. - Dividing by 0 gives positive or negative infinity depending on the numerator.
Product | Versions 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.
-
net8.0
- LinkDotNet.StringBuilder (>= 2.4.0)
-
net9.0
- LinkDotNet.StringBuilder (>= 2.4.0)
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.