30 int i = 0, length = 0, j = 0;
39 for(j = 0; j < length; ++j)
41 if((str[j] == 69) || (str[j] == 101))
52 if((flag_e) && (pos_e == 0))
54 if((flag_e) && (pos_e == length-1))
57 if((str[0] == 46) && (length == 1))
70 for(i = 0; i < length; ++i)
80 for(i = 0; i < length; ++i)
87 else if(i == length-1)
91 else if((str[i] == 46) && (flag_dot > 0))
99 if((flag_dot) && (pos_dot >= (pos_e-1)))
104 for(i = 0; i < length; ++i)
108 else if((str[i] == 46) && (flag_dot > 0))
110 else if(str[i] == 46)
128 double result = 0.0, super_script = 0.0;
129 int idx = 0, dot = -2;
133 char * after_e = number;
136 length = strlen(number);
138 for(j = 0; j < length; ++j)
144 after_e = number + pos_e + 1;
152 super_script =
str2num(after_e);
153 result = result * pow(10.0, sign * super_script);
157 while(number[idx] != 0)
159 if(number[idx] == 46)
171 for (i = 0; i <= dot; ++i)
172 result += (
double)(number[i] - 48)*pow(10, dot - i);
175 for (i = 1; i < length - dot; ++i)
176 result += (
double)(number[dot+i] - 48)*pow(0.1, i);
int format_string(char *str)
This function examine whether a string represents a real number.
double str2num(char *number)
This function transform a string consisting '1', '2', ..., and '.' into the real number that it repre...