public static int encodeNumeric(PositionedByteRange dst, double val, Order ord) {
    if (val == 0.0) {
      dst.put(ord.apply(ZERO));
      return 1;
    }
    if (Double.isNaN(val)) {
      dst.put(ord.apply(NAN));
      return 1;
    }
    if (val == Double.NEGATIVE_INFINITY) {
      dst.put(ord.apply(NEG_INF));
      return 1;
    }
    if (val == Double.POSITIVE_INFINITY) {
      dst.put(ord.apply(POS_INF));
      return 1;
    }
    return encodeNumeric(dst, BigDecimal.valueOf(val), ord);
  }
Encode a numerical value using the variable-length encoding.
@param dst The destination to which encoded digits are written.
@param val The value to encode.
@param ord The {@link Order} to respect while encoding {@code val}.
@return the number of bytes written.
hbase-common/src/main/java/org/apache/hadoop/hbase/util/OrderedBytes.java