I've created a small program that takes a scientific notation value (i.e. 1x10^10), and displays its full value (I'm practising parameter passing by the way, hence why I created a separate subroutine):
static void Main(string[] args)
{
Console.Write("Enter a scientific notation number: ");
string num = Console.ReadLine();
Console.Write(ConvertString(num));
Console.ReadKey();
}
static double ConvertString(string num)
{
string[] Array = num.Split('x');
string[] Array2 = Array[1].Split('^');
double multiplier = (Convert.ToDouble(Array[0]));
double value = (Convert.ToDouble(Array2[0]));
double power = (Convert.ToDouble(Array2[1]));
double conversion = multiplier * Math.Pow(value, power);
return conversion;
}
It works fine when 'power' is less than 15. However, when it's greater than or equal to 15, the console displays 'E+x' (where 'x' is 'power') instead of the full value. For example:
1x10^5: 100000
1x10^10: 10000000000
1x10^15: 1E+15
This is the same case for negative powers as well. When 'power' is greater than or equal to -5, it displays 'E-x' instead:
1x10^-1: 0.1
1x10^-2: 0.01
1x10^-5: 1E-05
Is there any way to prevent this? Thanks.