⚠ Deprecated: Other, Legacy
newest package have this embedded
Suggested alternative: Electroincute.MathX.Numbers
.net standard 2.0 version it use a heap allocation represent a number, as if ensure a number is not truncate by IEEE standard.
$ dotnet add package Meow.Math.Fractionthis is a repo that use 2 BigInteger that represent a fraction
when calculate it manipulate on BigInteger (thus numerator/denominator) when transcribe out, it calculate and output the number.
it use a
heap allocationrepresent a number, as if ensure a number is not truncate by IEEE standard.
public readonly struct Fraction
{
private readonly BigInteger num;
private readonly BigInteger den;
}
Fraction a = 1;
a /= 3;
it auto (implicit) convert the type of any Integer Type into Fraction
it auto (implicit) convert the type of any Double Type into Fraction
but
DoubleType only record the first15 digit(valid) whichmaycause issues.
which is percise.still in percise mode, which do as numerator and denominator.print it into none percise mode, it will calculate into specific digit.[operator] {var} >> {int}, this operator let you get percise digit number of a fraction.[operator] ! {var} , this operator simplify the fraction.[operator] ~ {var} , this operator try turning the fraction into a complex fraction.Fraction a = 52163;
a /= 16604;
Console.WriteLine(a >> 20); // (3, 14159238737653577451)
Console.WriteLine(a >> 50); // (3, 14159238737653577451216574319441098530474584437484)
Console.WriteLine(~a); // (3, 2351 / 16604)
Console.WriteLine(!a); // 52163 / 16604