fix shift_round overflow error
This commit is contained in:
parent
d1aa2f04c4
commit
9f0b3eb77e
@ -17,7 +17,7 @@ pub type Complex<T> = (T, T);
|
|||||||
/// Shifted and rounded value.
|
/// Shifted and rounded value.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn shift_round(x: i32, shift: usize) -> i32 {
|
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.
|
/// Integer division, round up half.
|
||||||
|
Loading…
Reference in New Issue
Block a user