Changeset 17811 for trunk/HeuristicLab.Problems.DataAnalysis.Symbolic
- Timestamp:
- 12/31/20 15:39:28 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/InfixExpressionFormatter.cs
r17685 r17811 29 29 using HeuristicLab.Core; 30 30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 31 using Microsoft.SqlServer.Server;32 31 33 32 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 39 38 // operators 40 39 if (token == "+" || token == "-" || token == "OR" || token == "XOR" || 41 token == "*" || token == "/" || token == "AND" || 42 token == "^") { 40 token == "*" || token == "/" || token == "AND") { 43 41 strBuilder.Append("("); 44 42 FormatRecursively(node.Subtrees.First(), strBuilder, numberFormat, formatString, constants); … … 47 45 strBuilder.Append(" ").Append(token).Append(" "); 48 46 FormatRecursively(subtree, strBuilder, numberFormat, formatString, constants); 47 } 48 49 strBuilder.Append(")"); 50 } else if (token == "^") { 51 // handle integer powers directly 52 strBuilder.Append("("); 53 FormatRecursively(node.Subtrees.First(), strBuilder, numberFormat, formatString, constants); 54 55 var power = node.GetSubtree(1); 56 if(power is ConstantTreeNode constNode && Math.Truncate(constNode.Value) == constNode.Value) { 57 strBuilder.Append(" ").Append(token).Append(" ").Append(constNode.Value.ToString(formatString, numberFormat)); 58 } else { 59 strBuilder.Append(" ").Append(token).Append(" "); 60 FormatRecursively(power, strBuilder, numberFormat, formatString, constants); 49 61 } 50 62 … … 131 143 } else if (node.Symbol is Constant) { 132 144 var constNode = node as ConstantTreeNode; 133 if (constants==null && constNode.Value < 0) {145 if (constants == null && constNode.Value < 0) { 134 146 strBuilder.Append("(").Append(constNode.Value.ToString(formatString, numberFormat)) 135 147 .Append(")"); // (-1
Note: See TracChangeset
for help on using the changeset viewer.