@@ -32,7 +32,7 @@ def msum(iterable):
32
32
for x in iterable:
33
33
i = 0
34
34
for y in partials:
35
- if abs(x) < abs(y):
35
+ if abs(x) < abs(y):
36
36
x, y = y, x
37
37
hi = x + y
38
38
lo = y - (hi - x)
@@ -41,7 +41,7 @@ def msum(iterable):
41
41
i += 1
42
42
x = hi
43
43
partials[i:] = [x]
44
- return sum_exact(partials
44
+ return sum_exact(partials)
45
45
* </pre>
46
46
* <p>
47
47
* The {@code C} source code behind that method is:
@@ -64,9 +64,9 @@ def msum(iterable):
64
64
PyFPE_START_PROTECT("fsum", Py_DECREF(iter); return NULL)
65
65
66
66
for(;;) {
67
- assert(0 < = n && n < = m);
68
- assert((m == NUM_PARTIALS && p == ps) ||
69
- (m > NUM_PARTIALS && p != NULL));
67
+ assert(0 < = n && n < = m);
68
+ assert((m == NUM_PARTIALS && p == ps) ||
69
+ (m > NUM_PARTIALS && p != NULL));
70
70
71
71
item = PyIter_Next(iter);
72
72
if (item == NULL) {
@@ -80,9 +80,9 @@ def msum(iterable):
80
80
goto _fsum_error;
81
81
82
82
xsave = x;
83
- for (i = j = 0; j < n; j++) {
83
+ for (i = j = 0; j < n; j++) {
84
84
y = p[j];
85
- if (fabs(x) < fabs(y)) {
85
+ if (fabs(x) < fabs(y)) {
86
86
t = x; x = y; y = t;
87
87
}
88
88
hi = x + y;
@@ -106,7 +106,7 @@ def msum(iterable):
106
106
special_sum += xsave;
107
107
n = 0;
108
108
}
109
- else if (n > = m && _fsum_realloc(&p, n, ps, &m))
109
+ else if (n > = m && _fsum_realloc(& p, n, ps, & m))
110
110
goto _fsum_error;
111
111
else
112
112
p[n++] = x;
@@ -123,20 +123,20 @@ else if (n >= m && _fsum_realloc(&p, n, ps, &m))
123
123
}
124
124
125
125
hi = 0.0;
126
- if (n > 0) {
126
+ if (n > 0) {
127
127
hi = p[--n];
128
- while (n > 0) {
128
+ while (n > 0) {
129
129
x = hi;
130
130
y = p[--n];
131
- assert(fabs(y) < fabs(x));
131
+ assert(fabs(y) < fabs(x));
132
132
hi = x + y;
133
133
yr = hi - x;
134
134
lo = y - yr;
135
135
if (lo != 0.0)
136
136
break;
137
137
}
138
- if (n > 0 && ((lo < 0.0 && p[n-1] < 0.0) ||
139
- (lo > 0.0 && p[n-1] > 0.0))) {
138
+ if (n > 0 && ((lo < 0.0 && p[n-1] < 0.0) ||
139
+ (lo > 0.0 && p[n-1] > 0.0))) {
140
140
y = lo * 2.0;
141
141
x = hi + y;
142
142
yr = x - hi;
@@ -181,6 +181,7 @@ else if (n >= m && _fsum_realloc(&p, n, ps, &m))
181
181
* (in order to deal with the fact that {@code double} has a 52 bit
182
182
* mantissa and thus can only represent a subset of the 64 bit long values
183
183
* accurately).</li>
184
+ * </ol>
184
185
* <h2>Seel Also</h2>
185
186
* <ol>
186
187
* <li>http://code.activestate.com/recipes/393090-binary-floating-point-
0 commit comments