code: public static int encode(BigDecimal value, byte[] dst, int dstOffset) {
          if (value == null) {
              dst[dstOffset] = NULL_BYTE_HIGH;
              return 1;
          }
          int amt = encodeSignedVarInt(value.scale(), dst, dstOffset);
          return amt + encode(value.unscaledValue(), dst, dstOffset + amt);
      }
docs: Encodes the given optional BigDecimal into a variable amount of
  bytes. If the BigDecimal is null, exactly 1 byte is written. Otherwise,
  the amount written can be determined by calling calculateEncodedLength.
  
  @param value BigDecimal value to encode, may be null
  @param dst destination for encoded bytes
  @param dstOffset offset into destination array
  @return amount of bytes written
  @since 1.2