From: Kostya Shishkov Date: Tue, 26 Oct 2021 16:11:06 +0000 (+0200) Subject: core/intcode: fix unsigned to signed conversion function X-Git-Url: https://git.nihav.org/?p=nihav.git;a=commitdiff_plain;h=ffe6400ed1fffcac3dc114a38675b523efb0c916 core/intcode: fix unsigned to signed conversion function --- diff --git a/nihav-core/src/io/intcode.rs b/nihav-core/src/io/intcode.rs index 55c8f85..f5d1282 100644 --- a/nihav-core/src/io/intcode.rs +++ b/nihav-core/src/io/intcode.rs @@ -142,7 +142,7 @@ fn read_gammap(br: &mut BitReader) -> BitReaderResult { } fn uval_to_sval0mp(uval: u32) -> i32 { - if (uval & 1) != 0 { -((uval >> 1) as i32) } + if (uval & 1) != 0 { -(((uval + 1) >> 1) as i32) } else { (uval >> 1) as i32 } }