Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Python/atof.c

    r2 r391  
    1111double atof(char *s)
    1212{
    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;
     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;
    5050}
Note: See TracChangeset for help on using the changeset viewer.