code: public static int calculateEncodedLength(BigInteger value) {
          if (value == null) {
              return 1;
          }
          int bytesLength = (value.bitLength() >> 3) + 1;
          return bytesLength < 0x7f ? (1 + bytesLength) : (5 + bytesLength);
      }
docs: Returns the amount of bytes required to encode a BigInteger.
  
  @param value BigInteger value to encode, may be null
  @return amount of bytes needed to encode
  @since 1.2