code: function valToString(val, hasSign) {
  
        var str = "";
  
        if (Complex && val instanceof Complex) {
  
          if (val['im'] === 0) {
  
            if (val['re'] > 0 && hasSign) {
              str += "+";
            }
            str += val['re'];
  
          } else if (val['re'] === 0) {
  
            if (val['im'] === -1) {
              str += "-";
            } else if (val['im'] !== 1) {
  
              if (val['im'] > 0 && hasSign) {
                str += "+";
              }
              str += val['im'];
            } else {
              if (val['im'] > 0 && hasSign) {
                str += "+";
              }
            }
            str += "i";
  
          } else {
  
            if (hasSign) {
              str += "+";
            }
  
            str += "(";
            str += val.toString();
            str += ")";
          }
  
          return str;
  
        } else {
  
          if (val > 0 && hasSign) {
            str += "+";
          }
          str += val.toString();
        }
        return str;
      }
docs: TODO: DRY, Combine with toString function