I have a program that populates a grid with data from a device. The grid has a column of doubles (I am using the 3rd party grid, SourceGrid, an excellent C# project) and most of them are just dandy.
However, I have one really small number (.000086669) that gets converted to scientific notation (8.6669E-5) in the grid.
My application also has a feature to pull the values FROM the grid and write them to file. However, they have to be in double format still, and pulling out the values means I will get that dastardly 8.6669E-5!
I have tried the following to no avail (meaning, invalid format exception)
if (varDbRow[2].ToString().Contains("E")) // Check for scientific notation in the particular Cell
{
//If it exists, parse the value to remove the scientific notation
varDbRow[2] =
Double.Parse(varDbRow[2].ToString(), System.Globalization.NumberStyles.AllowExponent);
}
However, this doesn't work because the significand (8.6669) contains a decimal. D'oh
So I have thought about trying something using the string.Split() method, and adding zeros to the beginning (with decimal) or end (without decimal) of the significand depending on whether the mantissa (-5, in this case) is positive or negative. But that seems like a LOT of work for something that seems so simple.
Thoughts?

New Topic/Question
Reply




MultiQuote






|