Index: java/lang/Boolean.java =================================================================== RCS file: /cvs/classpath/java/lang/Boolean.java,v retrieving revision 1.14 diff -u -u -r1.14 Boolean.java --- java/lang/Boolean.java 2000/03/16 23:31:19 1.14 +++ java/lang/Boolean.java 2001/07/09 23:07:36 @@ -1,5 +1,5 @@ /* Boolean.java -- object wrapper for boolean - Copyright (C) 1998 Free Software Foundation, Inc. + Copyright (C) 1998, 2001 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -42,13 +42,17 @@ /** * This field is a Boolean object representing the - * primitive value true. + * primitive value true. This instance is returned + * by the static valueOf() methods if they return + * a Boolean representing true. */ public static final Boolean TRUE = new Boolean(true); /** * This field is a Boolean object representing the - * primitive value false. + * primitive value false. This instance is returned + * by the static valueOf() methods if they return + * a Boolean representing false. */ public static final Boolean FALSE = new Boolean(false); @@ -62,7 +66,9 @@ /** * Create a Boolean object representing the value of the - * argument value + * argument value. In general the use of the static + * method valueof(boolean) is more efficient since it will + * not create a new object. * * @param value the primitive value of this Boolean */ @@ -74,7 +80,9 @@ * Creates a Boolean object representing the primitive * true if and only if s matches * the string "true" ignoring case, otherwise the object will represent - * the primitive false. + * the primitive false. In general the use of the static + * method valueof(String) is more efficient since it will + * not create a new object. * * @param s the String representation of true * or false @@ -92,11 +100,23 @@ } /** - * Calls Boolean(String) to create the new object. - * @see #Boolean(java.lang.String) + * Returns the Boolean TRUE if the given boolean is + * true, otherwise it will return the Boolean + * FALSE. + * + * @since 1.4 + */ + public static Boolean valueOf(boolean b) { + return b ? TRUE : FALSE; + } + + /** + * Returns the Boolean TRUE if and only if the given + * String is equal, ignoring case, to the the String "true", otherwise + * it will return the Boolean FALSE. */ public static Boolean valueOf(String s) { - return new Boolean(s); + return "true".equalsIgnoreCase(s) ? TRUE : FALSE; } /** @@ -132,6 +152,17 @@ return (val != null && val.equalsIgnoreCase("true")); } + /** + * Returns "true" if the value of the give boolean is true and + * returns "false" if the value of the given boolean is false. + * + * @since 1.4 + */ + public static String toString(boolean b) + { + return b ? "true" : "false"; + } + /** * Returns "true" if the value of this object is true and * returns "false" if the value of this object is false. Index: java/lang/Double.java =================================================================== RCS file: /cvs/classpath/java/lang/Double.java,v retrieving revision 1.16 diff -u -u -r1.16 Double.java --- java/lang/Double.java 2001/06/25 04:43:56 1.16 +++ java/lang/Double.java 2001/07/09 23:07:36 @@ -1,5 +1,5 @@ /* Double.java -- object wrapper for double primitive - Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -305,20 +305,43 @@ */ public int compareTo(Double d) { - double x = d.doubleValue(); - - if (isNaN (value)) - return isNaN(x) ? 0 : 1; - if ((value == 0.0d) && (x == -0.0d)) + return compare(value, d.value); + } + + /** + * Returns 0 if the first argument is equal to the second argument. + * Returns a number less than zero if the first argument is less than the + * second argument, and returns a number greater than zero if the first + * argument is greater than the second argument. + *
+ * Double.NaN is greater than any number other than itself, + * even Double.POSITIVE_INFINITY. + *
+ * 0.0d is greater than -0.0d. + * + * @param x the first double to compare. + * @param y the second double to compare. + * @return 0 if the arguments are the same, < 0 if the + * first argument is less than the second argument in + * in question, or > 0 if it is greater. + * @since 1.4 + */ + public static int compare(double x, double y) + { + if (isNaN (x)) + return isNaN(y) ? 0 : 1; + if (isNaN (y)) + return -1; + if ((x == 0.0d) && (y == -0.0d)) return 1; - if ((value == -0.0d) && (x == 0.0d)) + if ((x == -0.0d) && (y == 0.0d)) return -1; - if (value == x) + if (x == y) return 0; - return (value > x) ? 1 : -1; + return (x > y) ? 1 : -1; } - + /** * Compares the specified Object to this Double * if and only if the Object is an instanceof Index: java/lang/Float.java =================================================================== RCS file: /cvs/classpath/java/lang/Float.java,v retrieving revision 1.15 diff -u -u -r1.15 Float.java --- java/lang/Float.java 2001/06/25 04:43:56 1.15 +++ java/lang/Float.java 2001/07/09 23:07:36 @@ -425,16 +425,41 @@ */ public int compareTo(Float f) { - float x = f.floatValue(); - - if (value == NaN) - return (x == NaN) ? 0 : 1; - if ((value == 0.0) && (x == -0.0)) + return compare(value, f.value); + } + + /** + * Returns 0 if the first argument is equal to the second argument. + * Returns a number less than zero if the first argument is less than the + * second argument, and returns a number greater than zero if the first + * argument is greater than the second argument. + *
+ * Float.NaN is greater than any number other than itself, + * even Float.POSITIVE_INFINITY. + *
+ * 0.0 is greater than -0.0. + * + * @param x the first float to compare. + * @param y the second float to compare. + * @return 0 if the arguments are the same, < 0 if the + * first argument is less than the second argument in + * in question, or > 0 if it is greater. + * @since 1.4 + */ + public static int compare(float x, float y) + { + if (isNaN (x)) + return isNaN (y) ? 0 : 1; + if (isNaN (y)) + return -1; + if ((x == 0.0) && (y == -0.0)) return 1; - if ((value == -0.0) && (x == 0.0)) + if ((x == -0.0) && (y == 0.0)) return -1; + if (x == y) + return 0; - return ((value - x) > 0) ? 1 : -1; + return (x > y) ? 1 : -1; } /**