BigInteger.ToString() returns more than 50 decimal digits.
- by brickner
I'm using .NET 4 System.Numerics.BigInteger Structure and I'm getting results different from the documentation.
In the documentation of BigInteger.ToString() Method It says:
The ToString() method supports 50
decimal digits of precision. That is,
if the BigInteger value has more than
50 digits, only the 50 most
significant digits are preserved in
the output string; all other digits
are replaced with zeros.
I have some code that takes a 60 decimal digits BigInteger and converts it to a string. The 60 significant decimal digits string didn't lose any significant digits:
const string vString = "123456789012345678901234567890123456789012345678901234567890";
Assert.AreEqual(60, vString.Length);
BigInteger v = BigInteger.Parse(vString);
Assert.AreEqual(60, v.ToString().Length);
Assert.AreEqual('9', v.ToString()[58]);
Assert.AreEqual('1', v.ToString()[0]);
Assert.AreEqual(vString, v.ToString());
All the asserts pass.
What exactly does the quoted part of the documentation mean?