mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2026-05-05 08:54:22 -04:00
fix zigzag decoding
This commit is contained in:
parent
36ff514792
commit
01004a3c92
2 changed files with 2 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue