From: Kostya Shishkov Date: Sat, 9 Jun 2018 17:28:25 +0000 (+0200) Subject: io: fix Elias gamma code reading X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=6036ce2832c9b06794569a514b2dda92c2ebe056;p=nihav.git io: fix Elias gamma code reading --- diff --git a/src/io/intcode.rs b/src/io/intcode.rs index 5e35a15..e876772 100644 --- a/src/io/intcode.rs +++ b/src/io/intcode.rs @@ -71,11 +71,11 @@ fn read_rice(br: &mut BitReader, k: u8) -> BitReaderResult { } fn read_gamma(br: &mut BitReader) -> BitReaderResult { - let mut ret = 0; + let mut ret = 1; while br.read(1)? != 1 { ret = (ret << 1) | br.read(1)?; } - Ok(ret) + Ok(ret - 1) } fn read_gammap(br: &mut BitReader) -> BitReaderResult {