We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fa50056 commit 96bf177Copy full SHA for 96bf177
stdlib/src/math.rs
@@ -343,10 +343,11 @@ mod math {
343
let correction = v
344
.iter()
345
.copied()
346
- .map(|x| (x / scale).pow(2))
+ .map(|x| (x / scale).powi(2))
347
.chain(std::iter::once(-norm * norm))
348
+ // Pairwise summation of floats gives less rounding error than a naive sum.
349
.tree_fold1(std::ops::Add::add)
- .unwrap();
350
+ .expect("expected at least 1 element");
351
norm = norm + correction / (2.0 * norm);
352
}
353
norm * scale
0 commit comments