I am trying to convert a double to a decimal using Convert.ToDecimal function. The problem is that somehow .net chooses to omit decimal digits depending on the size of original double variable.
Take the following example:
double d = 2999247013.972682;
decimal convDecimal = Convert.ToDecimal(d);
decimal realDecimal = 2999247013.972682M;
Console.WriteLine(d);
Console.WriteLine(convDecimal);
Console.WriteLine(realDecimal);
Which produces the following output:
2999247013,97268 // comments: (actual value 2999247013,972682)
2999247013,97268 // comments: (actual value 2999247013,97268)
2999247013,972682 // comments: (actual value 2999247013,972682)
(',' is the decimal separator on current locale)
What i am trying to achieve is to use a Convert.ToDecimal(d) and get the decimal number 2999247013,972682.
Any thoughts anyone?