- Workaround for bug with plotting when given INF value.
authorrichardgraham <richardgraham@180e2498-e6e9-4542-8430-84ac67f01cd8>
Fri, 14 Sep 2012 05:34:21 +0000 (05:34 +0000)
committerrichardgraham <richardgraham@180e2498-e6e9-4542-8430-84ac67f01cd8>
Fri, 14 Sep 2012 05:34:21 +0000 (05:34 +0000)
- Fixed bug with hashing which was not dependent on symbol and would thus give same hash for the range expressions applied to a different variable
- Fixed bug with hashing in which a < could weirdly show up due to unhandled - sign in original string hash

git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@1023 180e2498-e6e9-4542-8430-84ac67f01cd8

core/src/net/sf/openrocket/simulation/customexpression/CustomExpression.java

index 7102b55be9f24e3091e3c4a43c64c657d9b864de..e233deff992fdfcebb990801bb63289875072664 100644 (file)
@@ -352,7 +352,9 @@ public class CustomExpression implements Cloneable{
        }
        
        public Double evaluateDouble(SimulationStatus status){
-               return evaluate(status).getDoubleValue();
+               double result = evaluate(status).getDoubleValue();
+               if (result == Double.NEGATIVE_INFINITY || result == Double.POSITIVE_INFINITY) result = Double.NaN;
+               return result;
        }
        
        /*
@@ -498,9 +500,10 @@ public class CustomExpression implements Cloneable{
         * Used for temporary substitution when evaluating index and range expressions.
         */
        public String hash(){
-               Integer hashint = new Integer(this.getExpressionString().hashCode());
+               Integer hashint = new Integer(this.getExpressionString().hashCode() + symbol.hashCode());
                String hash = "$";
                for (char c : hashint.toString().toCharArray()){
+                       if (c == '-') c = '0';
                        char newc = (char) (c + 17);
                        hash = hash + newc;
                }