How do I prevent my double value from being rounded when converting to a string? I have tried both Convert.ToString and ToString() with the same r
I would assume that the main answer for rounding away the last two digits, is to hide numerical instability/rounding due to float/double finite precision.
Example with no rounding:
(Math.Sqrt(7)).ToString("G17") = "2.6457513110645907"
(Math.Sqrt(7)+6).ToString("G17") = "8.6457513110645898"
Looks a bit strange in the last 3 digits, right?
Example with rounding:
(Math.Sqrt(7)).ToString() = "2.64575131106459"
(Math.Sqrt(7)+6).ToString() = "8.64575131106459"
Look "perfect", right?
:-)