code: public String formatValue(double val) {
      NumberFormat fmt = NumberFormat.getInstance(Locale.US);
      fmt.setMaximumFractionDigits(-log10res);
      return fmt.format(val);
    }
docs: Format value according to the scales resolution (i.e. appropriate number of
  digits)
  
  @param val Value
  @return formatted number