OK, I've got a number (say 0.5004) and I using custom formatting I get into a string such as "5E-01". Now, my question is this, not using string methods (i.e. finding the index of "E" and use substring() to pull out the "-01" portion), is their a mathematical way to retrieve the integral value of "-01" in the scientific notated number? I'd like a method that would return the following values:

value s.n. return

0.5004 "5E-01" -1

5.004 "5E+01" +1

50.04 "5E+02" +2

etc.

Using the Math functions in C# is there a way to do this? It's been many, many years since I've taken a math course or cracked a math book, so this might be an easy question.

If there's not, would someone help me come up with the right algorithm using string methods? Thanks.

i don't know if there's anything build in (see the System.Math class)

if you really want to have a decimal equivalent of 5E-1 you can do something like this:

string text = "5E-01";

string[] values = text.ToLower().Split('e');

double val = double.Parse(values[0]);

int exponent = int.Parse(values[1]);

double ret = val * Math.Pow(10, exponent);