writeVarInt = (encoder, num) => {
  const isNegative = math.isNegativeZero(num);

  if (isNegative) {
    num = -num;
  } //             |- whether to continue reading         |- whether is negative     |- number


  write(encoder, (num > binary.BITS6 ? binary.BIT8 : 0) | (isNegative ? binary.BIT7 : 0) | binary.BITS6 & num);
  num >>>= 6; // We don't need to consider the case of num === 0 so we can use a different
  // pattern here than above.

  while (num > 0) {
    write(encoder, (num > binary.BITS7 ? binary.BIT8 : 0) | binary.BITS7 & num);
    num >>>= 7;
  }
}
Write a variable length integer.

Encodes integers in the range from [-2147483648, -2147483647].

We don't use zig-zag encoding because we want to keep the option open
to use the same function for BigInt and 53bit integers (doubles).

We use the 7th bit instead for signaling that this is a negative number.

@function
@param {Encoder} encoder
@param {number} num The number that is to be encoded.