Parse Scientific Notated Number
Posted on 2003-10-24
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
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.