public String toString()
  {
    double valueOfTheQuantity = this.value;
      Map<String,Integer> mapOfTheQuantity = this.unit;

      // Ensure we get the units in order
      TreeSet<String> orderedUnits =
      new TreeSet<String>(mapOfTheQuantity.keySet());
      StringBuffer unitsString = new StringBuffer();
        
    for (String key : orderedUnits) {
      int expt = mapOfTheQuantity.get(key);
        unitsString.append(" " + key);
        if (expt != 1)
        unitsString.append("^" + expt);
    }
      
    // Used to convert doubles to a string with a
    // fixed maximum number of decimal places.
    DecimalFormat df = new DecimalFormat("0.0####");
    
    // Put it all together and return.
    return df.format(valueOfTheQuantity)
        + unitsString.toString();
  }