Changeset 391 for python/trunk/Python/atof.c
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Python/atof.c
r2 r391 11 11 double atof(char *s) 12 12 { 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 13 double a = 0.0; 14 int e = 0; 15 int c; 16 while ((c = *s++) != '\0' && isdigit(c)) { 17 a = a*10.0 + (c - '0'); 18 } 19 if (c == '.') { 20 while ((c = *s++) != '\0' && isdigit(c)) { 21 a = a*10.0 + (c - '0'); 22 e = e-1; 23 } 24 } 25 if (c == 'e' || c == 'E') { 26 int sign = 1; 27 int i = 0; 28 c = *s++; 29 if (c == '+') 30 c = *s++; 31 else if (c == '-') { 32 c = *s++; 33 sign = -1; 34 } 35 while (isdigit(c)) { 36 i = i*10 + (c - '0'); 37 c = *s++; 38 } 39 e += i*sign; 40 } 41 while (e > 0) { 42 a *= 10.0; 43 e--; 44 } 45 while (e < 0) { 46 a *= 0.1; 47 e++; 48 } 49 return a; 50 50 }
Note:
See TracChangeset
for help on using the changeset viewer.