/// <summary> /// 判断输入的数是否是科学计数法。如果是的话,就会将其换算成整数并且返回,否则就返回false。 /// </summary> /// <param name="num"></param> /// <param name="CompleteNum"></param> /// <returns></returns> private bool ChkNum(string num, ref decimal CompleteNum) { bool result = false; bool resultSymbol = num.Contains("*"); bool result0 = num.Contains("^"); if ((resultSymbol == true) && (result0 == true)) { //当数字中有*和^的时候,进行下面的判断 int IntSymbol = num.IndexOf("*"); int Symbol0 = num.IndexOf("^"); if (((Symbol0 - IntSymbol) == 3)) {//当*在^前面的时候 string numA = num.Substring(0, IntSymbol);//截取*号前面的数字(基数); string numB = num.Substring(IntSymbol+1, Symbol0 - IntSymbol-1);//截取10; string numC = num.Substring(Symbol0+1, num.Length - Symbol0-1);//获得幂次数 Regex regNum0 = new Regex(@"^(-|+)?d+(.d+)?$"); Regex regNum2 = new Regex(@"^-[1-9]d*$|^[1-9]d*$"); if ((regNum0.IsMatch(numA)) && (numB == "10") && (regNum2.IsMatch(numC))) { decimal dcNumA; decimal.TryParse(numA,out dcNumA); decimal dcNumC; decimal.TryParse(numC, out dcNumC);//将幂次数转换成decimal类型 decimal zhengshu = 10; if (dcNumC > 0) {//当幂次数为整数的时候 for (int i = 0; i < dcNumC - 1; i++) { zhengshu *= 10; } } else {//当幂次数为负数的时候 for (int i = 0; i < Math.Abs(dcNumC) + 1; i++) { zhengshu /= 10; } } CompleteNum = dcNumA * zhengshu; result = true; } else { result = false; } } else { result = false; } } else { result = false; } return result; }