aboutsummaryrefslogtreecommitdiffstats
path: root/src/proguard/evaluation/value/ParticularDoubleValue.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/proguard/evaluation/value/ParticularDoubleValue.java')
-rw-r--r--src/proguard/evaluation/value/ParticularDoubleValue.java25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/proguard/evaluation/value/ParticularDoubleValue.java b/src/proguard/evaluation/value/ParticularDoubleValue.java
index 05bc559..e8c5aa7 100644
--- a/src/proguard/evaluation/value/ParticularDoubleValue.java
+++ b/src/proguard/evaluation/value/ParticularDoubleValue.java
@@ -2,7 +2,7 @@
* ProGuard -- shrinking, optimization, obfuscation, and preverification
* of Java bytecode.
*
- * Copyright (c) 2002-2009 Eric Lafortune (eric@graphics.cornell.edu)
+ * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -79,17 +79,23 @@ final class ParticularDoubleValue extends SpecificDoubleValue
public DoubleValue add(DoubleValue other)
{
- return value == 0.0 ? other : other.add(this);
+ // Careful: -0.0 + 0.0 == 0.0
+ //return value == 0.0 ? other : other.add(this);
+ return other.add(this);
}
public DoubleValue subtract(DoubleValue other)
{
- return value == 0.0 ? other.negate() : other.subtractFrom(this);
+ // Careful: -0.0 + 0.0 == 0.0
+ //return value == 0.0 ? other.negate() : other.subtractFrom(this);
+ return other.subtractFrom(this);
}
public DoubleValue subtractFrom(DoubleValue other)
{
- return value == 0.0 ? other : other.subtract(this);
+ // Careful: -0.0 + 0.0 == 0.0
+ //return value == 0.0 ? other : other.subtract(this);
+ return other.subtract(this);
}
public DoubleValue multiply(DoubleValue other)
@@ -128,7 +134,10 @@ final class ParticularDoubleValue extends SpecificDoubleValue
public DoubleValue generalize(ParticularDoubleValue other)
{
- return this.value == other.value ? this : ValueFactory.DOUBLE_VALUE;
+ // Also handle NaN and Infinity.
+ return Double.doubleToRawLongBits(this.value) ==
+ Double.doubleToRawLongBits(other.value) ?
+ this : ValueFactory.DOUBLE_VALUE;
}
public DoubleValue add(ParticularDoubleValue other)
@@ -191,8 +200,10 @@ final class ParticularDoubleValue extends SpecificDoubleValue
public boolean equals(Object object)
{
- return super.equals(object) &&
- this.value == ((ParticularDoubleValue)object).value;
+ // Also handle NaN and Infinity.
+ return super.equals(object) &&
+ Double.doubleToLongBits(this.value) ==
+ Double.doubleToLongBits(((ParticularDoubleValue)object).value);
}