private static int getBitWidth(int val) {
    int count = 0;
    while (val != 0) {
      count++;
      val = (byte) (val >>> 1);
    }
    return count;
  }
Minimum bits required to encode the specified value
@param val
         - input value
@return
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/common/ndv/hll/HyperLogLogUtils.java