public static string WriteFormat(double value)
{
// Special output condition when value = 0
if (value == 0)
{
return "0.000000".PadLeft(13);
}
// Maximum field width larger than max int so check against max int
if (value > .1 && value < 999999999999)
{
string temp = value.ToString();
// First check if the number does not have a decimal
if (temp.IndexOf(".") == -1)
{
var length = temp.Length;
if (value <1000000)
{
if (length >= 6)
{
return (value.ToString("G6") + " ").PadLeft(13);
}
var pad = 7 - length;
return (value.ToString() + ".".PadRight(pad, '0')+ " ").PadLeft(13);
}
}
}
return value.ToString("#.####0.0e+00").PadLeft(13);
}