diff --git a/dsp/src/lib.rs b/dsp/src/lib.rs index 77d8bc1..6f521f1 100644 --- a/dsp/src/lib.rs +++ b/dsp/src/lib.rs @@ -17,7 +17,7 @@ pub type Complex = (T, T); /// Shifted and rounded value. #[inline(always)] pub fn shift_round(x: i32, shift: usize) -> i32 { - (x + (1 << (shift - 1))) >> shift + x.saturating_add(1 << (shift - 1)) >> shift } /// Integer division, round up half.