diff --git a/qendpoint-core/src/main/java/com/the_qa_company/qendpoint/core/compact/integer/VByte.java b/qendpoint-core/src/main/java/com/the_qa_company/qendpoint/core/compact/integer/VByte.java index d17aa76d..b3f7f78b 100644 --- a/qendpoint-core/src/main/java/com/the_qa_company/qendpoint/core/compact/integer/VByte.java +++ b/qendpoint-core/src/main/java/com/the_qa_company/qendpoint/core/compact/integer/VByte.java @@ -275,6 +275,11 @@ public static int sizeOf(long number) { } public static int sizeOfSigned(long number) { - return (BitUtil.log2(number) - 1) / 7 + 1 + 1; + if (number < 0) { + // set the 1st bit to 1 + return sizeOf(~(number << 1)); + } else { + return sizeOf(number << 1); + } } }