public static int lenIonDecimal(BigDecimal bd)
    {
        // first check for the special cases of null
        // and 0d0 which are encoded in the nibble
        if (bd == null) return 0;
        if (isNibbleZero(bd)) return 0;

        // otherwise do this the hard way
        BigInteger mantissa = bd.unscaledValue();

        // negative zero mantissa must be written, positive zero does not
        boolean forceMantissa = Decimal.isNegativeZero(bd);
        int mantissaByteCount = lenInt(mantissa, forceMantissa);

        // We really need the length of the exponent (-scale) but in our
        // representation the length is the same regardless of sign.
        int scale = bd.scale();
        int exponentByteCount = lenVarInt(scale);

        // Exponent is always at least one byte.
        if (exponentByteCount == 0) exponentByteCount = 1;

        return exponentByteCount + mantissaByteCount;
    }
public static int lenIonDecimal ( BigDecimal bd ) { if ( bd == null ) return 0 ; if ( isNibbleZero ( bd ) ) return 0 ; BigInteger mantissa = bd . unscaledValue ( ) ; boolean forceMantissa = Decimal . isNegativeZero ( bd ) ; int mantissaByteCount = lenInt ( mantissa , forceMantissa ) ; int scale = bd . scale ( ) ; int exponentByteCount = lenVarInt ( scale ) ; if ( exponentByteCount == 0 ) exponentByteCount = 1 ; return exponentByteCount + mantissaByteCount ; }
@param bd must not be null.