code: public UnitValue convert(UnitValue value, UnitFactorSet factorSet) {
      value = convert(value, factorSet.base());
      BigDecimal n = value.amount();
      
      // Use absolute value to simplify comparisons with divisors
      boolean negative = false;
      if (n.signum() == -1) {
        negative = true;
        n = n.abs();
      }
      
      List<UnitValue> factors = factorSet.factors();
      int size = factors.size();
      int last = size - 1;
      for (int i = 0; i < size; i++) {
        UnitValue factor = factors.get(i);
        BigDecimal divisor = factor.amount();
        if (divisor == null) {
          continue;
        }
        
        // Use this divisor if it is <= the number or if we've run out of
        // factors to try.
        if (divisor.compareTo(n) <= 0 || i == last) {
          int scale = n.precision() + divisor.precision();
          n = n.divide(divisor, scale, RoundingMode.HALF_EVEN);
          if (negative) {
            n = n.negate();
          }
          return new UnitValue(n.stripTrailingZeros(), factor.unit());
        }
      }
  
      // Should only be reached if list of factors is empty.
      return value;
    }
docs: Convert to the best display unit among the available factors. By "best"
  we mean the most compact representation.