B2017-168 Fixed logic to handle Fortran Formatted numbers
This commit is contained in:
@@ -783,19 +783,25 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private string DoFortranFormat(string text)
|
private string DoFortranFormat(string text)
|
||||||
{
|
{
|
||||||
if (text.IndexOf(@".E") < 0) return text;
|
//if (text.IndexOf(@".E") < 0) return text;
|
||||||
// Look for text as n.Ey, where n can be null or a number, and y can be
|
// Look for text as n.Ey, where n can be null or a number, and y can be
|
||||||
// positive or negative. This translates into nx10x10y where y is
|
// positive or negative. This translates into nx10x10y where y is
|
||||||
// superscripted. For example, .E3 -> x103 where 3 is superscripted
|
// superscripted. For example, .E3 -> x103 where 3 is superscripted
|
||||||
// and 10.E5 -> 10x10-5 where 5 is superscripted
|
// and 10.E5 -> 10x10-5 where 5 is superscripted
|
||||||
string pat = @"(\d*).E([+-]*\d+)";
|
// B2017-168 Fixed Regular Expression to cover more examples
|
||||||
|
// +1.25E6 1.25E6 -1.25E6 +2.E6 2.E6 -2.E6 +1.E6 1.E6 -1.E6 .E2
|
||||||
|
string pat = @"(\d*\.\d*)E(([-+]|\\u8209\?)?\d+)";
|
||||||
string retstr = text;
|
string retstr = text;
|
||||||
// for each one that needs translated:
|
// for each one that needs translated:
|
||||||
foreach (Match m in Regex.Matches(text, pat))
|
foreach (Match m in Regex.Matches(text, pat))
|
||||||
{
|
{
|
||||||
string fnum = m.Groups[1].Value;
|
string fnum = m.Groups[1].Value;
|
||||||
string supnum = m.Groups[2].Value;
|
string supnum = m.Groups[2].Value;
|
||||||
string newstr = string.Format(@"{0}x10\up2 {1}\up0 ", fnum, supnum);
|
string newstr;
|
||||||
|
if (fnum == "1.0" || fnum == "1." || fnum == ".")
|
||||||
|
newstr = string.Format(@"10\up2 {0}\up0 ", supnum);
|
||||||
|
else
|
||||||
|
newstr = string.Format(@"{0}x10\up2 {1}\up0 ", fnum, supnum);
|
||||||
retstr = retstr.Replace(m.Value, newstr);
|
retstr = retstr.Replace(m.Value, newstr);
|
||||||
}
|
}
|
||||||
return retstr;
|
return retstr;
|
||||||
|
Reference in New Issue
Block a user