protected void putDecimal(String name, BSONDecimal decimal) { int size = decimal.getSize(); int typemod = decimal.getTypemod(); short signscale = decimal.getSignScale(); short weight = decimal.getWeight(); short[] digits = decimal.getDigits(); // decimal is kept in bson in follow format: // type+name+size+typemod+dscale+weight+digits // put type+name _put(NUMBER_DECIMAL, name); // size+typemod+dscale+weight+data _buf.writeInt(size); _buf.writeInt(typemod); _buf.writeShort(signscale); _buf.writeShort(weight); for (int i = 0; i < digits.length; i++) { _buf.writeShort(digits[i]); } }