BigRational ToDecimalString(int digits),Parse and TryParse

May 10, 2013 at 4:34 AM
I'd like to see the addition of NaN, PositiveInfinity and NegativeInfinity as per double.
Also the functions Parse and TryParse

I use BigRational to create c++ defines for quad precision floating point number constants so please add a ToDecimalString(int digits)
e.g. something like below
public string ToDecimalString(int digits)
{
       string bigTenS = "1".PadRight(digits + 1, '0');
        BigInteger bigTen = BigInteger.Parse(bigTenS);
        BigInteger num = BigInteger.Divide(BigInteger.Multiply(this.Numerator, bigTen), this.Denominator);
        var sign = string.Empty;
        if (num < 0)
        {
            sign = "-";
            num = -num;
        }

        var numString = num.ToString();
        numString = numString.PadLeft(digits, '0');
        numString = numString.Substring(0, numString.Length - digits) + "." + numString.Substring(numString.Length - digits, digits);
        if (numString.StartsWith("."))
        {
            numString = "0" + numString;
        }
        return sign + numString;
}