public static int calculateEncodedLength(BigDecimal value) {
        if (value == null) {
            return 1;
        }
        return signedVarIntLength(value.scale()) + calculateEncodedLength(value.unscaledValue());
    }
public static int calculateEncodedLength ( BigDecimal value ) { if ( value == null ) { return 1 ; } return signedVarIntLength ( value . scale ( ) ) + calculateEncodedLength ( value . unscaledValue ( ) ) ; }
Returns the amount of bytes required to encode the given BigDecimal.

@param value BigDecimal value to encode, may be null
@return amount of bytes needed to encode
@since 1.2