8000 WIP · RustPython/RustPython@4f8d25b · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f8d25b

Browse files
committed
WIP
Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
1 parent f2f892c commit 4f8d25b

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

stdlib/src/math.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -635,11 +635,11 @@ mod math {
635635
let mut x = *obj?;
636636

637637
let xsave = x;
638-
let mut j = 0;
638+
let mut i = 0;
639639
// This inner loop applies `hi`/`lo` summation to each
640640
// partial so that the list of partial sums remains exact.
641-
for i in 0..partials.len() {
642-
let mut y: f64 = partials[i];
641+
for j in 0..partials.len() {
642+
let mut y: f64 = partials[j];
643643
if x.abs() < y.abs() {
644644
std::mem::swap(&mut x, &mut y);
645645
}
@@ -648,8 +648,8 @@ mod math {
648648
let hi = x + y;
649649
let lo = y - (hi - x);
650650
if lo != 0.0 {
651-
partials[j] = lo;
652-
j += 1;
651+
partials[i] = lo;
652+
i += 1;
653653
}
654654
x = hi;
655655
}
@@ -668,15 +668,11 @@ mod math {
668668
special_sum += xsave;
669669
// reset partials
670670
partials.clear();
671-
}
672-
673-
if j >= partials.len() {
674-
partials.push(x);
675671
} else {
676-
partials[j] = x;
677-
partials.truncate(j + 1);
672+
partials.push(x);
678673
}
679674
}
675+
680676
if special_sum != 0.0 {
681677
return if inf_sum.is_nan() {
682678
Err(vm.new_value_error("-inf + inf in fsum".to_owned()))

0 commit comments

Comments
 (0)
0