public string ToDecimalString(int maxDecimalPlaces) { if (maxDecimalPlaces < 0) { throw new ArgumentOutOfRangeException("maxDecimalPlaces"); } bool isNegative = Numerator < 0; var numerator = isNegative ? Numerator.AsImmutable().Negate() : Numerator.AsImmutable(); var denominator = Denominator.AsImmutable(); mpz tail; var integerPart = numerator.TDivQR(denominator, out tail); var fractionalPart = mpz.Ten.AsMutable().Power(maxDecimalPlaces).Multiply(tail).TDivQ(denominator); return((isNegative ? "-" : String.Empty) + integerPart + "." + fractionalPart.ToString().PadLeft(maxDecimalPlaces, '0').TrimEnd('0')); }