Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit a52ff87

Browse files
committed
Fix overflow bug in fma
1 parent 4420289 commit a52ff87

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

src/math/fma.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ pub fn fma(x: f64, y: f64, z: f64) -> f64 {
126126
} else {
127127
/* r -= z */
128128
let t = rlo;
129-
rlo -= zlo;
130-
rhi = rhi - zhi - (t < rlo) as u64;
129+
rlo = rlo.wrapping_sub(zlo);
130+
rhi = rhi.wrapping_sub(zhi.wrapping_sub((t < rlo) as u64));
131131
if (rhi >> 63) != 0 {
132132
rlo = (-(rlo as i64)) as u64;
133133
rhi = (-(rhi as i64)) as u64 - (rlo != 0) as u64;

tests/unit.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)