Negative double zero is considered as less than 0, and not equals to positive zero. And NaN is considered large than Infinity.
#debug
var a as double = 0.0;
var b as double = -0.0;
print(a);
print(b);
print(a==b);
print(-a);
print(-b);
print(-b==a);
print(a>0);
print(a==0);
print(b<0);
print(b==0);
print(0.0/0.0 > 1.0/0.0);//NaN > Positive Infinity
output:
0.0
-0.0
false
-0.0
0.0
true
false
true
true
false
true
That's may because it calls Double.compare().
import com.blamejared.crafttweaker.api.CraftTweakerGlobals;
public class Test {
public static void run() {
double a = 0.0;
double b = -0.0;
CraftTweakerGlobals.print(Double.toString(a));
CraftTweakerGlobals.print(Double.toString(b));
CraftTweakerGlobals.print(Boolean.toString(Double.compare(a, b) == 0));
CraftTweakerGlobals.print(Double.toString(-a));
CraftTweakerGlobals.print(Double.toString(-b));
CraftTweakerGlobals.print(Boolean.toString(Double.compare(-b, a) == 0));
CraftTweakerGlobals.print(Boolean.toString(Double.compare(a, (double)0) > 0));
CraftTweakerGlobals.print(Boolean.toString(Double.compare(a, (double)0) == 0));
CraftTweakerGlobals.print(Boolean.toString(Double.compare(b, (double)0) < 0));
CraftTweakerGlobals.print(Boolean.toString(Double.compare(b, (double)0) == 0));
CraftTweakerGlobals.print(Boolean.toString(Double.compare(0.0 / 0.0, 1.0 / 0.0) > 0));
}
}
Negative double zero is considered as less than 0, and not equals to positive zero. And NaN is considered large than Infinity.
output:
That's may because it calls
Double.compare().