fix zigzag decoding

This commit is contained in:
Simon Cruanes 2026-02-10 01:48:59 +00:00
parent 36ff514792
commit 01004a3c92
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 2 additions and 2 deletions

View file

@ -60,7 +60,7 @@ module Decode = struct
Int64.to_int v, n_consumed
let[@inline] decode_zigzag (v : int64) : int64 =
Int64.(logxor (shift_right v 1) (neg (logand v Int64.one)))
Int64.(logxor (shift_right_logical v 1) (sub 0L (logand v 1L)))
let[@inline] i64 sl off : int64 * int =
let v, n_consumed = u64 sl off in

View file

@ -72,7 +72,7 @@ true
t @@ fun () ->
let buf = Buf.create () in
Leb128.Encode.u64 buf 1L;
Leb128.Encode.u64 buf 0L;
let slice = Buf.to_slice buf in
let v, n = Leb128.Decode.u64 slice 0 in
assert_equal ~printer:Int64.to_string 0L v;