This entry was posted on Monday, November 2nd, 2009 at 2:04 pm and is filed under Tech Stuff. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
I ran into a problem the other day with .NET’s Convert.ToDecimal() , it turns out that it doesn’t handle scientific Notation! Pass it something like “8E-5″ and the poor thing just throws an exception…
The software in which the problem surfaced was developed as a web application that must deal with numbers read from an Excel chart and so the formats encountered are many and varied!
This post points out that you can use this instead:
Decimal.Parse(val, System.Globalization.NumberStyles.AllowExponent);
But just to be safe I am now using:
Decimal.Parse(val, System.Globalization.NumberStyles.Any);
And it does work for Exponents, hopefully along with everything else!
