From ffe6400ed1fffcac3dc114a38675b523efb0c916 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Tue, 26 Oct 2021 18:11:06 +0200 Subject: [PATCH] core/intcode: fix unsigned to signed conversion function --- nihav-core/src/io/intcode.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 } } -- 2.39.5