private static BigDecimal decodeNumericValue(PositionedByteRange src) {
    final int e;
    byte header = src.get();
    boolean dsc = -1 == Integer.signum(header);
    header = dsc ? DESCENDING.apply(header) : header;

    if (header == NULL) return null;
    if (header == NEG_LARGE) { /* Large negative number: 0x08, ~E, ~M */
      e = (int) getVaruint64(src, !dsc);
      return decodeSignificand(src, e, !dsc).negate();
    }
    if (header >= NEG_MED_MIN && header <= NEG_MED_MAX) {
      /* Medium negative number: 0x13-E, ~M */
      e = NEG_MED_MAX - header;
      return decodeSignificand(src, e, !dsc).negate();
    }
    if (header == NEG_SMALL) { /* Small negative number: 0x14, -E, ~M */
      e = (int) -getVaruint64(src, dsc);
      return decodeSignificand(src, e, !dsc).negate();
    }
    if (header == ZERO) {
      return BigDecimal.ZERO;
    }
    if (header == POS_SMALL) { /* Small positive number: 0x16, ~-E, M */
      e = (int) -getVaruint64(src, !dsc);
      return decodeSignificand(src, e, dsc);
    }
    if (header >= POS_MED_MIN && header <= POS_MED_MAX) {
      /* Medium positive number: 0x17+E, M */
      e = header - POS_MED_MIN;
      return decodeSignificand(src, e, dsc);
    }
    if (header == POS_LARGE) { /* Large positive number: 0x22, E, M */
      e = (int) getVaruint64(src, dsc);
      return decodeSignificand(src, e, dsc);
    }
    throw unexpectedHeader(header);
  }
Decode a {@link BigDecimal} from {@code src}. Assumes {@code src} encodes a value in Numeric
encoding and is within the valid range of {@link BigDecimal} values. {@link BigDecimal} does
not support {@code NaN} or {@code Infinte} values.
@see #decodeNumericAsDouble(PositionedByteRange)
hbase-common/src/main/java/org/apache/hadoop/hbase/util/OrderedBytes.java