I have the following:
string value = "9223372036854775807";
double parsedVal = double.Parse(value, CultureInfo.InvariantCulture);
... and the result is 9.2233720368547758E+18
which is not the exact same number. How should I convert string to double without loss of precision?
double
can only guarantee 16 (approx) decimal digits of accuracy. You might try switching to decimal
(which has a few more bits to play with, and holds that value with plenty of headroom).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With