Skip to content

Commit 96bf177

Browse files
Respond to reviewer comments
1 parent fa50056 commit 96bf177

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

stdlib/src/math.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,11 @@ mod math {
343343
let correction = v
344344
.iter()
345345
.copied()
346-
.map(|x| (x / scale).pow(2))
346+
.map(|x| (x / scale).powi(2))
347347
.chain(std::iter::once(-norm * norm))
348+
// Pairwise summation of floats gives less rounding error than a naive sum.
348349
.tree_fold1(std::ops::Add::add)
349-
.unwrap();
350+
.expect("expected at least 1 element");
350351
norm = norm + correction / (2.0 * norm);
351352
}
352353
norm * scale

0 commit comments

Comments
 (0)