The comments don't match the code for Math.min:
/**
* Return whichever argument is smaller.
* @param a the first number
* @param b a second number
* @return the smaller of the two numbers.
*/
public static float min(float a, float b) {
if (a == 0.0f && b == 0.0f) // return -0.0f, if a or b is -0.0f
return ((Float.floatToIntBits(a) >> 31) == 1) ? a : b;
return (a < b) ? a : b;
}
/**
* Return whichever argument is smaller.
* @param a the first number
* @param b a second number
* @return the smaller of the two numbers.
*/
public static double min(double a, double b) {
if (a == 0.0d && b == 0.0d) // return -0.0d, if a or b is -0.0d
return ((Double.doubleToLongBits(a) >> 63) == 1) ? a : b;
return (a < b) ? a : b;
}
These mauve tests fail on my JVM:
harness.check (Double.toString (Math.min (Double.NaN, 2.0)), "NaN");
harness.check (Double.toString (Math.min (Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY)),
"-Infinity");
harness.check (Double.toString (Math.min (Double.NEGATIVE_INFINITY, 0.0)),
"-Infinity");
harness.check (Float.toString (Math.min (-1.0f, -2.0f)), "-2.0");
harness.check (Float.toString (Math.min (2.0f, Float.NaN)), "NaN");
harness.check (Float.toString (Math.min (Float.NaN, 2.0f)), "NaN");
harness.check (Float.toString (Math.min (Float.NEGATIVE_INFINITY,
Float.POSITIVE_INFINITY)),
"-Infinity");
harness.check (Float.toString (Math.min (Float.NEGATIVE_INFINITY, 0.0f)),
"-Infinity");
John Leuner
_______________________________________________
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath