private bool CheckRulePreExponentRule(char c, int i, ref PreExponentRules preExponentRules) { if (i == 0) { if (c == '-' || c == '+') { return(true); } if (c == '.') { return(false); } if (c == '0') { preExponentRules.IsSmallerThan1 = true; return(true); } } if (i == 1 && c == '0' && preExponentRules.IsSmallerThan1) { return(false); } if (c == '-' || c == '+') { return(false); } if (c == '.') { if (preExponentRules.IsDecimal) { return(false); } if (!preExponentRules.IsDecimal) { preExponentRules.IsDecimal = true; return(true); } if (preExponentRules.IsSmallerThan1 && i != 1) { return(false); } } return(c >= '0' && c <= '9'); }
private bool ValidatePreExponentPart(string preExponentSign) { if (string.IsNullOrWhiteSpace(preExponentSign)) { return(false); } if (preExponentSign.StartsWith(".")) { return(false); } var preExponentRules = new PreExponentRules(); for (int i = 0; i < preExponentSign.Length; i++) { if (!CheckRulePreExponentRule(preExponentSign[i], i, ref preExponentRules)) { return(false); } } return(true); }