code: private int percent(final long val, final long total) {
          if (total == 0) {
              return 100;
          }
  
          if (val == 0) {
              return 0;
          }
  
          double dVal = (double) val;
          double dTotal = (double) total;
  
          return (int) (dVal / dTotal * 100);
      }
docs: Compute the percent values.
  
  @param val
  The value to be represented in percent
  @param total
  The total value
  @return The percent of val/total