Open sungam3r opened 5 years ago
public static string ReplaceUnaryMinus(string formula) { var newFormula = new StringBuilder(); string prev = formula[0].ToString(); for (int i = 0; i < formula.Length; i++) { char symbol = formula[i]; if (symbol == '-' && (prev != ")" && definedOperators.ContainsKey(prev) || prev == "=")) // GCop178 { newFormula.Append(UNARY_MINUS); } else { newFormula.Append(symbol); } prev = symbol.ToString(); } return newFormula.ToString(); }
After quick fix:
public static string ReplaceUnaryMinus(string formula) { var newFormula = new StringBuilder(); string prev = formula[0].ToString(); for (int i = 0; i < formula.Length; i++) { char symbol = formula[i]; if (symbol == '-' && ((prev != ")" && definedOperators.ContainsKey(prev)) || prev == "=")) // still GCop178 { newFormula.Append(UNARY_MINUS); } else { newFormula.Append(symbol); } prev = symbol.ToString(); } return newFormula.ToString(); }
After quick fix: