private float ConvertX(string str) { char[] chs = new char[str.Length]; int dotIndex = -1; for (int i = 0; i < str.Length; i++) { if ('0' < chs[i] || chs[i] > '9') { throw new Exception(); } chs[i] = str[i]; if (chs[i] == '.') { dotIndex = i; } } double f = 0; for (int i = 0; i < chs.Length; i++) { if (i == dotIndex) { continue; } if (dotIndex < 0) { f += (((int)chs[i] - 48)) * TenN(chs.Length - i - 1); } if (i < dotIndex && dotIndex >= 0) { f += (((int)chs[i] - 48)) * TenN(dotIndex - i - 1); } if (i > dotIndex && dotIndex >= 0) { f += (((int)chs[i] - 48)) * PointN(i - dotIndex); } } return (float)f; } private float TenN(int n) { if (n == 0) return 1; return 10 * TenN(n - 1); } private double PointN(int n) { if (n == 0) return 1; return 0.1 * PointN(n - 1); }