allan.jacobs@Eng 1997-02-28
Math.abs(-0.0f) returns -0.0f. Math.abs(-0.0d) returns -0.0d
in violation of the Java Spec. Turning on the JIT fixes the problem.
algol% cat zero.java
class zero {
public static void main( String[] argv ) {
float fz = -0.0F;
double dz = -0.0D;
System.out.println( Math.abs(fz) );
System.out.println( Math.abs(dz) );
}
}
algol% javac zero.java
algol% java -Djava.compiler=none zero
-0.0
-0.0
algol% java -Djava.compiler=sunwjit zero
0.0
0.0
- duplicates
-
JDK-4098041 Math.abs(-0.0F) and abs(-0.0D) must return +0.0, and not -0.0 according to JLS
-
- Closed
-