docs: private void writeDecimalValue(final BigDecimal value)
      {
          final boolean isNegZero = isNegativeZero(value);
          final int signum = value.signum();
          final int exponent = -value.scale();
  
          writeVarInt(exponent);
  
          final BigInteger mantissaBigInt = value.unscaledValue();
          if (mantissaBigInt.compareTo(BIG_INT_LONG_MIN_VALUE) >= 0 && mantissaBigInt.compareTo(BIG_INT_LONG_MAX_VALUE) <= 0)
          {
              // we can fit into the long space
              final long mantissa = mantissaBigInt.longValue();
              if (signum == 0 && !isNegZero)
              {
                  // positive zero does not need to be encoded
              }
              else if (isNegZero)
              {
                  // XXX special case for negative zero, we have to encode as a signed zero in the Int format
                  updateLength(1);
                  buffer.writeByte(DECIMAL_NEGATIVE_ZERO_MANTISSA);
              }
              else if (mantissa == Long.MIN_VALUE)
              {
                  // XXX special case for min value -- we need 64-bits to store the magnitude and we need a bit for sign
                  updateLength(9);
                  buffer.writeUInt8(0x80);
                  buffer.writeUInt64(mantissa);
              }
              else if (mantissa >= 0xFFFFFFFFFFFFFF81L && mantissa <= 0x000000000000007FL)
              {
                  updateLength(1);
                  buffer.writeInt8(mantissa);
              }
              else if (mantissa >= 0xFFFFFFFFFFFF8001L && mantissa <= 0x0000000000007FFFL)
              {
                  updateLength(2);
                  buffer.writeInt16(mantissa);
              }
              else if (mantissa >= 0xFFFFFFFFFF800001L && mantissa <= 0x00000000007FFFFFL)
              {
                  updateLength(3);
                  buffer.writeInt24(mantissa);
              }
              else if (mantissa >= 0xFFFFFFFF80000001L && mantissa <= 0x000000007FFFFFFFL)
              {
                  updateLength(4);
                  buffer.writeInt32(mantissa);
              }
              else if (mantissa >= 0xFFFFFF8000000001L && mantissa <= 0x0000007FFFFFFFFFL)
              {
                  updateLength(5);
                  buffer.writeInt40(mantissa);
              }
              else if (mantissa >= 0xFFFF800000000001L && mantissa <= 0x00007FFFFFFFFFFFL)
              {
                  updateLength(6);
                  buffer.writeInt48(mantissa);
              }
              else if (mantissa >= 0xFF80000000000001L && mantissa <= 0x007FFFFFFFFFFFFFL)
              {
                  updateLength(7);
                  buffer.writeInt56(mantissa);
              }
              else
              {
                  // TODO consider being more space efficient for integers that can be written with 6/7 bytes.
                  updateLength(8);
                  buffer.writeInt64(mantissa);
              }
          }
          else
          {
              final BigInteger magnitude = signum > 0 ? mantissaBigInt : mantissaBigInt.negate();
              final byte[] bits = magnitude.toByteArray();
              if (signum < 0)
              {
                  if ((bits[0] & 0x80) == 0)
                  {
                      bits[0] |= 0x80;
                  }
                  else
                  {
                      // not enough space in the bits to store the negative sign
                      updateLength(1);
                      buffer.writeUInt8(0x80);
                  }
              }
              updateLength(bits.length);
              buffer.writeBytes(bits);
          }
      }