public static BigDecimal toBigDecimal(ByteBuffer buffer, int offset, int length) {
    if (buffer == null || length < Bytes.SIZEOF_INT + 1 || (offset + length > buffer.limit())) {
      return null;
    }

    int scale = toInt(buffer, offset);
    byte[] tcBytes = new byte[length - Bytes.SIZEOF_INT];
    copyFromBufferToArray(tcBytes, buffer, offset + Bytes.SIZEOF_INT, 0, length - Bytes.SIZEOF_INT);
    return new BigDecimal(new BigInteger(tcBytes), scale);
  }
Reads a BigDecimal value at the given buffer's offset.
@param buffer input bytebuffer to read
@param offset input offset
@return BigDecimal value at offset
hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java