private static void encodeToCentimal(PositionedByteRange dst, BigDecimal val) {
    // The input value val must be in [0.01, 1.0)
    String stringOfAbs = val.stripTrailingZeros().toPlainString();
    String value = stringOfAbs.substring(stringOfAbs.indexOf('.') + 1);
    int d;

    // If the first float digit is 0, we will encode one digit more than MAX_PRECISION
    // We encode at most MAX_PRECISION significant digits into centimals,
    // because the input value, has been already normalized.
    int maxPrecision = value.charAt(0) == '0' ? MAX_PRECISION + 1 : MAX_PRECISION;
    maxPrecision = Math.min(maxPrecision, value.length());
    for (int i = 0; i < maxPrecision; i += 2) {
      d = (value.charAt(i) - '0') * 10;
      if (i + 1 < maxPrecision) {
        d += (value.charAt(i + 1) - '0');
      }
      dst.put((byte) (2 * d + 1));
    }
  }
Encode a value val in [0.01, 1.0) into Centimals. Util function for
{@link OrderedBytes#encodeNumericLarge(PositionedByteRange, BigDecimal)} and
{@link OrderedBytes#encodeNumericSmall(PositionedByteRange, BigDecimal)}
@param dst The destination to which encoded digits are written.
@param val A BigDecimal after the normalization. The value must be in [0.01, 1.0).
hbase-common/src/main/java/org/apache/hadoop/hbase/util/OrderedBytes.java