2

When I try to display a very small or a very big number, it shows us the number with the e notation.
How do I bypass this issue?

Things I have tried:

Console.WriteLine(Double.Parse("1E-10", System.Globalization.NumberStyles.Float));
/* System.FormatException: Input string was not in a correct format.
 *     at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
 *     at Rextester.Program.Main(String[] args)
 */
Console.WriteLine(Convert.ToString(Math.Pow(10,-10)));
// returns 1E-10
double num = Math.Pow(10,-10);
Console.WriteLine(num.ToString());
// returns 1E-10
NOT_A_ROBOT
  • 113
  • 1
  • 15

1 Answers1

2

For this one you need to use a string format. For your case Pow(10, -10) will return 0.0000000001, so you will need to use a format that can display 10 decimal places.

You may declare a string format like this:

const string format = "0.##########";

Then use: Console.WriteLine(num.ToString(format));

Kinin Roza
  • 1,908
  • 1
  • 7
  • 17