[Solved] C# BigInteger remainder as fraction


This seems to work:

BigInteger a = new(5678);
BigInteger b = new(1234);

BigInteger div = BigInteger.DivRem(a, b, out BigInteger rem);

var decimalDigits = new List<BigInteger>();

while (rem != 0 && decimalDigits.Count < 10)
{
    rem *= 10;
    decimalDigits.Add(BigInteger.DivRem(rem, b, out rem));
}

Console.WriteLine($"{div}.{string.Concat(decimalDigits)}");

This is pretty much just an implementation of long division.

1

solved C# BigInteger remainder as fraction