Until today I (implicitly) assumed that when I output a BigInteger
via the parameterless (overridden) instance method BigInteger.ToString()
then the return string would contain the complete and exact decimal representation of my "big" integer.
But on the MSDN doc page I read:
"In most cases, 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. However, BigInteger supports the "R" standard format specifier, which is intended to round-trip numeric values. The string returned by the ToString(String) method with the "R" format string preserves the whole BigInteger value and can then be parsed with the Parse or TryParse method to restore its original value without any loss of data"._
However, I have not been able to find an example where myBigInt.ToString()
differs from myBigInt.ToString("R")
. The Remarks example from the above page does not, as claimed, provide an example, in my version of the framework (.NET 4.0 SP1). (Also "G"
and "R"
seem to be equivalent for BigInteger
.)
Is it safe to assume that the paramterless ToString()
gives the full decimal expansion of the integer? Did they change framework behavior, or has the above mentioned example code always been wrong?
Note: SO shows me this "similar question" 2984184 after I wrote this one, but I'm still submitting my question because the answer of 2984184 does not really claryfy how the zero-parameter ToString()
works.
EDIT BY MYSELF:
It was a bit incosequent of me to link the ToString(String)
overload on MSDN when my question is (primarily) about the ToString()
overload. So see also MSDN on BigInteger.ToString()
which mentions the 50 digits limit as well but does not provide an example with more than 50 digits.