How can I display the number with just the 2 not=zero decimals?
Example:
For 0.00045578 I want 0.00045 and for 1.0000533535 I want 1.000053
You can use this trick:
int d, whole; double number = 0.00045578; string format; whole = (int)number; d = 1; format = "0.0"; while (Math.Floor(number * Math.Pow(10, d)) / Math.Pow(10, d) == whole) { d++; format += "0"; } format += "0"; Console.WriteLine(number.ToString(format));