Skip to content

Commit

Permalink
Merge pull request #59 from Gusarich/main
Browse files Browse the repository at this point in the history
fix: size calculation in varint serialization
  • Loading branch information
dvlkv authored Dec 19, 2024
2 parents 00fa47e + 8a67b1b commit af9f776
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/boc/BitBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class BitBuilder {

// Calculate size
let v2 = v > 0 ? v : -v;
const sizeBytes = 1 + Math.ceil((v2.toString(2).length) / 8); // Fastest way in most environments
const sizeBytes = Math.ceil((v2.toString(2).length + 1) / 8); // Fastest way in most environments
const sizeBits = sizeBytes * 8;

// Write size
Expand Down

0 comments on commit af9f776

Please # to comment.