code: static double unitFactor( String leftUnit, String rightUnit, boolean fail ) {
          if( leftUnit.length() == 0 || rightUnit.length() == 0 || leftUnit.equals( rightUnit ) ) {
              return 1;
          }
          HashMap<String, Double> leftGroup = UNIT_CONVERSIONS.get( leftUnit );
          if( leftGroup != null ) {
              HashMap<String, Double> rightGroup = UNIT_CONVERSIONS.get( rightUnit );
              if( leftGroup == rightGroup ) {
                  return leftGroup.get( leftUnit ) / leftGroup.get( rightUnit );
              }
          }
          if( fail ) {
              throw new LessException( "Incompatible types" );
          }
          return 1;
      }
docs: Calculate the factor between 2 units.
  
  @param leftUnit left unit
  @param rightUnit right unit
  @param fail true, should be fail if units incompatible; false, return 1 is incompatible
  @return the factor between the 2 units.
  @throws LessException if unit are incompatible and fail is true