changeset 809:f3ad2ee4600b

6601457: Move wrapper class tests from closed to open 6601458: Move java.math tests from closed to open 6740185: Move java/lang/annotations tests to open 6759433: Move Math and StrictMath regression tests from closed to open Summary: Move some more regression tests to the open Reviewed-by: jjg
author darcy
date Mon, 26 Jan 2009 19:49:26 -0800
parents 175b6adf65b3
children 2113813eda62 53d9259661c3
files test/java/lang/Boolean/Factory.java test/java/lang/Boolean/GetBoolean.java test/java/lang/Boolean/MakeBooleanComparable.java test/java/lang/Boolean/ParseBoolean.java test/java/lang/Byte/Decode.java test/java/lang/Double/BitwiseConversion.java test/java/lang/Double/Constants.java test/java/lang/Double/Extrema.java test/java/lang/Double/NaNInfinityParsing.java test/java/lang/Double/ParseDouble.java test/java/lang/Double/ParseHexFloatingPoint.java test/java/lang/Double/ToHexString.java test/java/lang/Float/BitwiseConversion.java test/java/lang/Float/Constants.java test/java/lang/Float/Extrema.java test/java/lang/Float/NaNInfinityParsing.java test/java/lang/Float/ParseFloat.java test/java/lang/Integer/BitTwiddle.java test/java/lang/Integer/Decode.java test/java/lang/Integer/GetInteger.java test/java/lang/Integer/ParsingTest.java test/java/lang/Long/BitTwiddle.java test/java/lang/Long/Decode.java test/java/lang/Long/GetLong.java test/java/lang/Long/ParsingTest.java test/java/lang/Math/AbsPositiveZero.java test/java/lang/Math/Atan2Tests.java test/java/lang/Math/CubeRootTests.java test/java/lang/Math/Expm1Tests.java test/java/lang/Math/HyperbolicTests.java test/java/lang/Math/HypotTests.java test/java/lang/Math/IeeeRecommendedTests.java test/java/lang/Math/Log10Tests.java test/java/lang/Math/Log1pTests.java test/java/lang/Math/MinMax.java test/java/lang/Math/PowTests.java test/java/lang/Math/Rint.java test/java/lang/Math/TanTests.java test/java/lang/Math/Tests.java test/java/lang/Short/ByteSwap.java test/java/lang/Short/Decode.java test/java/lang/StrictMath/CubeRootTests.java test/java/lang/StrictMath/Expm1Tests.java test/java/lang/StrictMath/HyperbolicTests.java test/java/lang/StrictMath/HypotTests.java test/java/lang/StrictMath/Log10Tests.java test/java/lang/StrictMath/Log1pTests.java test/java/lang/StrictMath/Tests.java test/java/lang/ToString.java test/java/lang/annotation/AnnotationTypeMismatchException/FoundType.java test/java/lang/annotation/Missing/A.java test/java/lang/annotation/Missing/B.java test/java/lang/annotation/Missing/C.java test/java/lang/annotation/Missing/D.java test/java/lang/annotation/Missing/Marker.java test/java/lang/annotation/Missing/Missing.java test/java/lang/annotation/Missing/MissingTest.java test/java/lang/annotation/Missing/MissingWrapper.java test/java/lang/annotation/PackageMain.java test/java/lang/annotation/RecursiveAnnotation.java test/java/lang/annotation/UnitTest.java test/java/lang/annotation/loaderLeak/A.java test/java/lang/annotation/loaderLeak/B.java test/java/lang/annotation/loaderLeak/C.java test/java/lang/annotation/loaderLeak/LoaderLeak.sh test/java/lang/annotation/loaderLeak/Main.java test/java/lang/annotation/package-info.java test/java/math/BigDecimal/AddTests.java test/java/math/BigDecimal/CompareToTests.java test/java/math/BigDecimal/Constructor.java test/java/math/BigDecimal/DivideTests.java test/java/math/BigDecimal/FloatDoubleValueTests.java test/java/math/BigDecimal/IntegralDivisionTests.java test/java/math/BigDecimal/NegateTests.java test/java/math/BigDecimal/PowTests.java test/java/math/BigDecimal/RoundingTests.java test/java/math/BigDecimal/ScaleByPowerOfTenTests.java test/java/math/BigDecimal/SerializationTests.java test/java/math/BigDecimal/StringConstructor.java test/java/math/BigDecimal/StrippingZerosTest.java test/java/math/BigDecimal/ToPlainStringTests.java test/java/math/BigDecimal/ZeroScalingTests.java test/java/math/BigInteger/BigIntegerTest.java test/java/math/BigInteger/ModPow.java test/java/math/BigInteger/ModPow65537.java test/java/math/BigInteger/ModPowPowersof2.java test/java/math/BigInteger/OperatorNpeTests.java test/java/math/BigInteger/ProbablePrime.java test/java/math/BigInteger/StringConstructor.java test/java/math/BigInteger/UnicodeConstructor.java test/java/math/RoundingMode/RoundingModeTests.java
diffstat 91 files changed, 21518 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Boolean/Factory.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4262398
+ * @summary Basic test for Boolean.valueOf(boolean b).
+ */
+
+public class Factory {
+    public static void main(String[] args) throws Exception {
+        if (Boolean.valueOf(true) != Boolean.TRUE)
+            throw new Exception("Truth failure");
+        if (Boolean.valueOf(false) != Boolean.FALSE)
+            throw new Exception("Major fallacy");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Boolean/GetBoolean.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright 1999 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4252308
+ * @summary test Boolean.getBoolean method with empty key
+ */
+
+public class GetBoolean {
+    public static void main(String[] args) throws Exception {
+        Boolean.getBoolean("");
+        Boolean.getBoolean(null);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Boolean/MakeBooleanComparable.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     4329937
+ * @summary Basic test for making Boolean implement Comparable
+ * @author  Josh Bloch
+ *
+ * @compile -source 1.5 MakeBooleanComparable.java
+ * @run main MakeBooleanComparable
+ */
+
+import java.util.*;
+
+public class MakeBooleanComparable {
+    public static void main(String args[]) {
+        Random rnd = new Random();
+        List<Boolean> list = new ArrayList<Boolean>();
+        int numFalse = 0;
+        for (int i = 0; i < 1000; i++) {
+            boolean element = rnd.nextBoolean();
+            if (!element)
+                numFalse++;
+            list.add(element); // Autoboxing!
+        }
+
+        Collections.sort(list);
+
+        for (int i = 0; i < numFalse; i++)
+            if (list.get(i).booleanValue())  // Autounboxing doesn't work yet!
+                throw new RuntimeException("False positive: " + i);
+        for (int i = numFalse; i < 1000; i++)
+            if (!list.get(i).booleanValue()) // Autounboxing doesn't work yet!
+                throw new RuntimeException("False negative: " + i);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Boolean/ParseBoolean.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4253773
+ * @summary test Boolean.parseBoolean
+ */
+
+public class ParseBoolean {
+    public static void main(String[] args) throws Exception {
+        checkTrue(Boolean.parseBoolean("TRUE"));
+        checkTrue(Boolean.parseBoolean("true"));
+        checkTrue(Boolean.parseBoolean("TrUe"));
+
+        checkFalse(Boolean.parseBoolean("false"));
+        checkFalse(Boolean.parseBoolean("FALSE"));
+        checkFalse(Boolean.parseBoolean("FaLse"));
+        checkFalse(Boolean.parseBoolean(null));
+        checkFalse(Boolean.parseBoolean("garbage"));
+        checkFalse(Boolean.parseBoolean("TRUEE"));
+    }
+
+    static void checkTrue(boolean b) {
+        if (!b)
+            throw new RuntimeException("test failed");
+    }
+
+    static void checkFalse(boolean b) {
+        if (b)
+            throw new RuntimeException("test failed");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Byte/Decode.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,98 @@
+/*
+ * Copyright 1999-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4242173 5017980 6576055
+ * @summary Test Byte.decode method
+ * @author madbot
+ * @author Joseph D. Darcy
+ */
+
+/**
+ * There are six methods in java.lang.Byte which transform strings
+ * into a byte or Byte value:
+ *
+ * public Byte(String s)
+ * public static Byte decode(String nm)
+ * public static byte parseByte(String s, int radix)
+ * public static byte parseByte(String s)
+ * public static Byte valueOf(String s, int radix)
+ * public static Byte valueOf(String s)
+ *
+ * However, of these only decode has a nontrivial implementation
+ * in that class.
+ */
+public class Decode {
+
+    private static void check(String val, byte expected) {
+        byte n = (Byte.decode(val)).byteValue();
+        if (n != expected)
+            throw new RuntimeException("Byte.decode failed. String:" +
+                                                val + " Result:" + n);
+    }
+
+    private static void checkFailure(String val, String message) {
+        try {
+            byte n = (Byte.decode(val)).byteValue();
+            throw new RuntimeException(message);
+        } catch (NumberFormatException e) { /* Okay */}
+    }
+
+    public static void main(String[] args) throws Exception {
+        check(new String(""+Byte.MIN_VALUE), Byte.MIN_VALUE);
+        check(new String(""+Byte.MAX_VALUE), Byte.MAX_VALUE);
+
+        check("10",   (byte)10);
+        check("0x10", (byte)16);
+        check("0X10", (byte)16);
+        check("010",  (byte)8);
+        check("#10",  (byte)16);
+
+        check("+10",   (byte)10);
+        check("+0x10", (byte)16);
+        check("+0X10", (byte)16);
+        check("+010",  (byte)8);
+        check("+#10",  (byte)16);
+
+        check("-10",   (byte)-10);
+        check("-0x10", (byte)-16);
+        check("-0X10", (byte)-16);
+        check("-010",  (byte)-8);
+        check("-#10",  (byte)-16);
+
+        check(Integer.toString((int)Byte.MIN_VALUE), Byte.MIN_VALUE);
+        check(Integer.toString((int)Byte.MAX_VALUE), Byte.MAX_VALUE);
+
+        checkFailure("0x-10",   "Byte.decode allows negative sign in wrong position.");
+        checkFailure("0x+10",   "Byte.decode allows positive sign in wrong position.");
+
+        checkFailure("+",       "Raw plus sign allowed.");
+        checkFailure("-",       "Raw minus sign allowed.");
+
+        checkFailure(Integer.toString((int)Byte.MIN_VALUE - 1), "Out of range");
+        checkFailure(Integer.toString((int)Byte.MAX_VALUE + 1), "Out of range");
+
+        checkFailure("", "Empty String");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Double/BitwiseConversion.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 5037596
+ * @summary Verify bitwise conversion works for non-canonical NaN values
+ * @author Joseph D. Darcy
+ */
+
+import static java.lang.Double.*;
+import static sun.misc.DoubleConsts.*;
+
+public class BitwiseConversion {
+    static int testNanCase(long x) {
+        int errors  = 0;
+        // Strip out sign and exponent bits
+        long y = x & SIGNIF_BIT_MASK;
+
+        double values[] = {
+            longBitsToDouble(EXP_BIT_MASK | y),
+            longBitsToDouble(SIGN_BIT_MASK | EXP_BIT_MASK | y)
+        };
+
+        for(double value: values) {
+            if (!isNaN(value)) {
+                throw new RuntimeException("Invalid input " + y +
+                                           "yielded non-NaN" + value);
+            }
+            long converted = doubleToLongBits(value);
+            if (converted != 0x7ff8000000000000L) {
+                errors++;
+                System.err.format("Non-canoncial NaN bits returned: %x%n",
+                                  converted);
+            }
+        }
+        return errors;
+    }
+
+    public static void main(String... argv) {
+        int errors = 0;
+
+        for (int i = 0; i < SIGNIFICAND_WIDTH-1; i++) {
+            errors += testNanCase(1L<<i);
+        }
+
+        if (doubleToLongBits(Double.POSITIVE_INFINITY)
+                != 0x7ff0000000000000L) {
+            errors++;
+            System.err.println("Bad conversion for +infinity.");
+        }
+
+        if (doubleToLongBits(Double.NEGATIVE_INFINITY)
+                != 0xfff0000000000000L) {
+            errors++;
+            System.err.println("Bad conversion for -infinity.");
+        }
+
+        if (errors > 0)
+            throw new RuntimeException();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Double/Constants.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2001-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @compile Constants.java
+ * @bug 4397405 4826652
+ * @summary Testing constant-ness of Double.{MIN_VALUE, MAX_VALUE}, etc.
+ * @author Joseph D. Darcy
+ */
+
+public class Constants {
+    /*
+     * This compile-only test is to make sure that the primitive
+     * public static final fields in java.lang.Double are "constant
+     * expressions" as defined by "The Java Language Specification,
+     * 2nd edition" section 15.28; a different test checks the values
+     * of those fields.
+     */
+    public static void main(String[] args) throws Exception {
+        int i = 0;
+        switch (i) {
+        case (int)Double.NaN:                   // 0
+            System.out.println("Double.NaN is a constant!");
+            break;
+        case (int)Double.MIN_VALUE + 1:         // 0 + 1
+            System.out.println("Double.MIN_VALUE is a constant!");
+            break;
+        case (int)Double.MIN_NORMAL + 2:        // 0 + 2
+            System.out.println("Double.MIN_NORMAL is a constant!");
+            break;
+        case Double.MIN_EXPONENT:               // -1022
+            System.out.println("Double.MIN_EXPONENT is a constant!");
+            break;
+        case Double.MAX_EXPONENT:               // 1023
+            System.out.println("Double.MAX_EXPONENT is a constant!");
+            break;
+        case (int)Double.MAX_VALUE - 1:         // Integer.MAX_VALUE - 1
+            System.out.println("Double.MAX_VALUE is a constant!");
+            break;
+        case (int)Double.POSITIVE_INFINITY:     // Integer.MAX_VALUE
+            System.out.println("Double.POSITIVE_INFINITY is a constant!");
+            break;
+        case (int)Double.NEGATIVE_INFINITY:     // Integer.MIN_VALUE
+            System.out.println("Double.NEGATIVE_INFINITY is a constant!");
+            break;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Double/Extrema.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2001-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4408489 4826652
+ * @summary Testing values of Double.{MIN_VALUE, MIN_NORMAL, MAX_VALUE}
+ * @author Joseph D. Darcy
+ */
+
+public class Extrema {
+    public static void main(String[] args) throws Exception {
+        if (Double.MIN_VALUE != Double.longBitsToDouble(0x1L))
+            throw new RuntimeException("Double.MIN_VALUE is not equal "+
+                                       "to longBitsToDouble(0x1L).");
+
+        if (Double.MIN_NORMAL != Double.longBitsToDouble(0x0010000000000000L))
+            throw new RuntimeException("Double.MIN_NORMAL is not equal "+
+                                       "to longBitsToDouble(0x0010000000000000L).");
+
+        if (Double.MAX_VALUE != Double.longBitsToDouble(0x7fefffffffffffffL))
+            throw new RuntimeException("Double.MAX_VALUE is not equal "+
+                                       "to longBitsToDouble(0x7fefffffffffffffL).");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Double/NaNInfinityParsing.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2001 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4428772
+ * @summary Testing recognition of "NaN" and "Infinity" strings
+ * @author Joseph D. Darcy
+ */
+
+
+public class NaNInfinityParsing {
+    /*
+     * Regression tests for:
+     * 4428772 -- Establish invariant for Float & Double classes and
+     * their string representations
+     *
+     * Added capability for parse{Float, Double} and related methods
+     * to recognize "NaN" and "Infinity" strings so that
+     * parseDouble(toString(d)) will always return the original
+     * floating-point value.
+     */
+
+    static String NaNStrings[] = {
+        "NaN",
+        "+NaN",
+        "-NaN"
+    };
+
+    static String infinityStrings[] = {
+        "Infinity",
+        "+Infinity",
+        "-Infinity",
+    };
+
+    static String invalidStrings[] = {
+        "+",
+        "-",
+        "@",
+        "N",
+        "Na",
+        "Nan",
+        "NaNf",
+        "NaNd",
+        "NaNF",
+        "NaND",
+        "+N",
+        "+Na",
+        "+Nan",
+        "+NaNf",
+        "+NaNd",
+        "+NaNF",
+        "+NaND",
+        "-N",
+        "-Na",
+        "-Nan",
+        "-NaNf",
+        "-NaNd",
+        "-NaNF",
+        "-NaND",
+        "I",
+        "In",
+        "Inf",
+        "Infi",
+        "Infin",
+        "Infini",
+        "Infinit",
+        "InfinitY",
+        "Infinityf",
+        "InfinityF",
+        "Infinityd",
+        "InfinityD",
+        "+I",
+        "+In",
+        "+Inf",
+        "+Infi",
+        "+Infin",
+        "+Infini",
+        "+Infinit",
+        "+InfinitY",
+        "+Infinityf",
+        "+InfinityF",
+        "+Infinityd",
+        "+InfinityD",
+        "-I",
+        "-In",
+        "-Inf",
+        "-Infi",
+        "-Infin",
+        "-Infini",
+        "-Infinit",
+        "-InfinitY",
+        "-Infinityf",
+        "-InfinityF",
+        "-Infinityd",
+        "-InfinityD",
+        "NaNInfinity",
+        "InfinityNaN",
+        "nan",
+        "infinity"
+    };
+
+    public static void main(String [] argv) throws Exception {
+        int i;
+        double d;
+
+        // Test valid NaN strings
+        for(i = 0; i < NaNStrings.length; i++) {
+            if(!Double.isNaN(d=Double.parseDouble(NaNStrings[i]))) {
+                throw new RuntimeException("NaN string ``" + NaNStrings[i]
+                                           + "'' did not parse as a NaN; returned " +
+                                           d + " instead.");
+            }
+        }
+
+        // Test valid Infinity strings
+        for(i = 0; i < infinityStrings.length; i++) {
+            if(!Double.isInfinite(d=Double.parseDouble(infinityStrings[i]))) {
+                throw new RuntimeException("Infinity string ``" +
+                                           infinityStrings[i] +
+                                           "'' did not parse as infinity; returned " +
+                                           d + "instead.");
+            }
+            // check sign of result
+
+            boolean negative = (infinityStrings[i].charAt(0) == '-');
+            if(d != (negative?Double.NEGATIVE_INFINITY:
+                          Double.POSITIVE_INFINITY))
+                throw new RuntimeException("Infinity has wrong sign;" +
+                                           (negative?"positive instead of negative.":
+                                            "negative instead of positive."));
+        }
+
+        // Test almost valid strings
+        for(i = 0; i < invalidStrings.length; i++) {
+            try {
+                double result;
+                d = Double.parseDouble(invalidStrings[i]);
+                throw new RuntimeException("Invalid string ``" +
+                                           invalidStrings[i]
+                                           +"'' parsed as " + d + ".");
+            }
+            catch(NumberFormatException e) {
+                // expected
+            }
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Double/ParseDouble.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,562 @@
+/*
+ * Copyright 2001-2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4160406 4705734 4707389 4826774 4895911
+ * @summary Test for Double.parseDouble method and acceptance regex
+ */
+
+import java.util.regex.*;
+
+public class ParseDouble {
+
+    private static void check(String val, double expected) {
+        double n = Double.parseDouble(val);
+        if (n != expected)
+            throw new RuntimeException("Double.parseDouble failed. String:" +
+                                                val + " Result:" + n);
+    }
+
+    private static void rudimentaryTest() {
+        check(new String(""+Double.MIN_VALUE), Double.MIN_VALUE);
+        check(new String(""+Double.MAX_VALUE), Double.MAX_VALUE);
+
+        check("10",     (double)  10.0);
+        check("10.0",   (double)  10.0);
+        check("10.01",  (double)  10.01);
+
+        check("-10",    (double) -10.0);
+        check("-10.00", (double) -10.0);
+        check("-10.01", (double) -10.01);
+    }
+
+
+    static  String badStrings[] = {
+        "",
+        "+",
+        "-",
+        "+e",
+        "-e",
+        "+e170",
+        "-e170",
+
+        // Make sure intermediate white space is not deleted.
+        "1234   e10",
+        "-1234   e10",
+
+        // Control characters in the interior of a string are not legal
+        "1\u0007e1",
+        "1e\u00071",
+
+        // NaN and infinity can't have trailing type suffices or exponents
+        "NaNf",
+        "NaNF",
+        "NaNd",
+        "NaND",
+        "-NaNf",
+        "-NaNF",
+        "-NaNd",
+        "-NaND",
+        "+NaNf",
+        "+NaNF",
+        "+NaNd",
+        "+NaND",
+        "Infinityf",
+        "InfinityF",
+        "Infinityd",
+        "InfinityD",
+        "-Infinityf",
+        "-InfinityF",
+        "-Infinityd",
+        "-InfinityD",
+        "+Infinityf",
+        "+InfinityF",
+        "+Infinityd",
+        "+InfinityD",
+
+        "NaNe10",
+        "-NaNe10",
+        "+NaNe10",
+        "Infinitye10",
+        "-Infinitye10",
+        "+Infinitye10",
+
+        // Non-ASCII digits are not recognized
+        "\u0661e\u0661", // 1e1 in Arabic-Indic digits
+        "\u06F1e\u06F1", // 1e1 in Extended Arabic-Indic digits
+        "\u0967e\u0967", // 1e1 in Devanagari digits
+
+        // JCK test lex03592m3
+        ".",
+
+        // JCK test lex03592m4
+        "e42",
+
+        // JCK test lex03592m5
+        ".e42",
+
+        // JCK test lex03592m6
+        "d",
+
+        // JCK test lex03592m7
+        ".d",
+
+        // JCK test lex03592m8
+        "e42d",
+
+        // JCK test lex03592m9
+        ".e42d",
+
+        // JCK test lex03593m10
+        "1A01.01125e-10d",
+
+        // JCK test lex03593m11
+        "2;3.01125e-10d",
+
+        // JCK test lex03593m12
+        "1_34.01125e-10d",
+
+        // JCK test lex03593m14
+        "202..01125e-10d",
+
+        // JCK test lex03593m15
+        "202,01125e-10d",
+
+        // JCK test lex03593m16
+        "202.03b4e-10d",
+
+        // JCK test lex03593m18
+        "202.06_3e-10d",
+
+        // JCK test lex03593m20
+        "202.01125e-f0d",
+
+        // JCK test lex03593m21
+        "202.01125e_3d",
+
+        // JCK test lex03593m22
+        "202.01125e -5d",
+
+        // JCK test lex03593m24
+        "202.01125e-10r",
+
+        // JCK test lex03593m25
+        "202.01125e-10ff",
+
+        // JCK test lex03593m26
+        "1234L.01",
+
+        // JCK test lex03593m27
+        "12ee-2",
+
+        // JCK test lex03593m28
+        "12e-2.2.2",
+
+        // JCK test lex03593m29
+        "12.01e+",
+
+        // JCK test lex03593m30
+        "12.01E",
+
+        // Bad hexadecimal-style strings
+
+        // Two leading zeros
+        "00x1.0p1",
+
+        // Must have hex specifier
+        "1.0p1",
+        "00010p1",
+        "deadbeefp1",
+
+        // Need an explicit fully-formed exponent
+        "0x1.0p",
+        "0x1.0",
+
+        // Exponent must be in decimal
+        "0x1.0pa",
+        "0x1.0pf",
+
+        // Exponent separated by "p"
+        "0x1.0e22",
+        "0x1.0e22",
+
+        // Need a signifcand
+        "0xp22"
+    };
+
+    static String goodStrings[] = {
+        "NaN",
+        "+NaN",
+        "-NaN",
+        "Infinity",
+        "+Infinity",
+        "-Infinity",
+        "1.1e-23f",
+        ".1e-23f",
+        "1e-23",
+        "1f",
+        "0",
+        "-0",
+        "+0",
+        "00",
+        "00",
+        "-00",
+        "+00",
+        "0000000000",
+        "-0000000000",
+        "+0000000000",
+        "1",
+        "2",
+        "1234",
+        "-1234",
+        "+1234",
+        "2147483647",   // Integer.MAX_VALUE
+        "2147483648",
+        "-2147483648",  // Integer.MIN_VALUE
+        "-2147483649",
+
+        "16777215",
+        "16777216",     // 2^24
+        "16777217",
+
+        "-16777215",
+        "-16777216",    // -2^24
+        "-16777217",
+
+        "9007199254740991",
+        "9007199254740992",     // 2^53
+        "9007199254740993",
+
+        "-9007199254740991",
+        "-9007199254740992",    // -2^53
+        "-9007199254740993",
+
+        "9223372036854775807",
+        "9223372036854775808",  // Long.MAX_VALUE
+        "9223372036854775809",
+
+        "-9223372036854775808",
+        "-9223372036854775809", // Long.MIN_VALUE
+        "-9223372036854775810",
+
+        // Culled from JCK test lex03591m1
+        "54.07140d",
+        "7.01e-324d",
+        "2147483647.01d",
+        "1.2147483647f",
+        "000000000000000000000000001.F",
+        "1.00000000000000000000000000e-2F",
+
+        // Culled from JCK test lex03592m2
+        "2.",
+        ".0909",
+        "122112217090.0",
+        "7090e-5",
+        "2.E-20",
+        ".0909e42",
+        "122112217090.0E+100",
+        "7090f",
+        "2.F",
+        ".0909d",
+        "122112217090.0D",
+        "7090e-5f",
+        "2.E-20F",
+        ".0909e42d",
+        "122112217090.0E+100D",
+
+        // Culled from JCK test lex03594m31 -- unicode escapes
+        "\u0035\u0031\u0034\u0039\u0032\u0033\u0036\u0037\u0038\u0030.1102E-209D",
+        "1290873\u002E12301e100",
+        "1.1E-10\u0066",
+
+        // Culled from JCK test lex03595m1
+        "0.0E-10",
+        "1E10",
+
+        // Culled from JCK test lex03691m1
+        "0.f",
+        "1f",
+        "0.F",
+        "1F",
+        "0.12d",
+        "1e-0d",
+        "12.e+1D",
+        "0e-0D",
+        "12.e+01",
+        "1e-01",
+
+        // Good hex strings
+        // Vary capitalization of separators.
+
+        "0x1p1",
+        "0X1p1",
+        "0x1P1",
+        "0X1P1",
+        "0x1p1f",
+        "0X1p1f",
+        "0x1P1f",
+        "0X1P1f",
+        "0x1p1F",
+        "0X1p1F",
+        "0x1P1F",
+        "0X1P1F",
+        "0x1p1d",
+        "0X1p1d",
+        "0x1P1d",
+        "0X1P1d",
+        "0x1p1D",
+        "0X1p1D",
+        "0x1P1D",
+        "0X1P1D",
+
+        "-0x1p1",
+        "-0X1p1",
+        "-0x1P1",
+        "-0X1P1",
+        "-0x1p1f",
+        "-0X1p1f",
+        "-0x1P1f",
+        "-0X1P1f",
+        "-0x1p1F",
+        "-0X1p1F",
+        "-0x1P1F",
+        "-0X1P1F",
+        "-0x1p1d",
+        "-0X1p1d",
+        "-0x1P1d",
+        "-0X1P1d",
+        "-0x1p1D",
+        "-0X1p1D",
+        "-0x1P1D",
+        "-0X1P1D",
+
+        "0x1p-1",
+        "0X1p-1",
+        "0x1P-1",
+        "0X1P-1",
+        "0x1p-1f",
+        "0X1p-1f",
+        "0x1P-1f",
+        "0X1P-1f",
+        "0x1p-1F",
+        "0X1p-1F",
+        "0x1P-1F",
+        "0X1P-1F",
+        "0x1p-1d",
+        "0X1p-1d",
+        "0x1P-1d",
+        "0X1P-1d",
+        "0x1p-1D",
+        "0X1p-1D",
+        "0x1P-1D",
+        "0X1P-1D",
+
+        "-0x1p-1",
+        "-0X1p-1",
+        "-0x1P-1",
+        "-0X1P-1",
+        "-0x1p-1f",
+        "-0X1p-1f",
+        "-0x1P-1f",
+        "-0X1P-1f",
+        "-0x1p-1F",
+        "-0X1p-1F",
+        "-0x1P-1F",
+        "-0X1P-1F",
+        "-0x1p-1d",
+        "-0X1p-1d",
+        "-0x1P-1d",
+        "-0X1P-1d",
+        "-0x1p-1D",
+        "-0X1p-1D",
+        "-0x1P-1D",
+        "-0X1P-1D",
+
+
+        // Try different significand combinations
+        "0xap1",
+        "0xbp1",
+        "0xcp1",
+        "0xdp1",
+        "0xep1",
+        "0xfp1",
+
+        "0x1p1",
+        "0x.1p1",
+        "0x1.1p1",
+
+        "0x001p23",
+        "0x00.1p1",
+        "0x001.1p1",
+
+        "0x100p1",
+        "0x.100p1",
+        "0x1.100p1",
+
+        "0x00100p1",
+        "0x00.100p1",
+        "0x001.100p1"
+    };
+
+    static String paddedBadStrings[];
+    static String paddedGoodStrings[];
+    static {
+        String pad = " \t\n\r\f\u0001\u000b\u001f";
+        paddedBadStrings = new String[badStrings.length];
+        for(int i = 0 ; i <  badStrings.length; i++)
+            paddedBadStrings[i] = pad + badStrings[i] + pad;
+
+        paddedGoodStrings = new String[goodStrings.length];
+        for(int i = 0 ; i <  goodStrings.length; i++)
+            paddedGoodStrings[i] = pad + goodStrings[i] + pad;
+
+    }
+
+
+    /*
+     * Throws an exception if <code>Input</code> is
+     * <code>exceptionalInput</code> and {@link Double.parseDouble
+     * parseDouble} does <em>not</em> throw an exception or if
+     * <code>Input</code> is not <code>exceptionalInput</code> and
+     * <code>parseDouble</code> throws an exception.  This method does
+     * not attempt to test whether the string is converted to the
+     * proper value; just whether the input is accepted appropriately
+     * or not.
+     */
+    private static void testParsing(String [] input,
+                                    boolean exceptionalInput) {
+        for(int i = 0; i < input.length; i++) {
+            double d;
+
+            try {
+                d = Double.parseDouble(input[i]);
+            }
+            catch (NumberFormatException e) {
+                if (! exceptionalInput) {
+                    throw new RuntimeException("Double.parseDouble rejected " +
+                                               "good string `" + input[i] +
+                                               "'.");
+                }
+                break;
+            }
+            if (exceptionalInput) {
+                throw new RuntimeException("Double.parseDouble accepted " +
+                                           "bad string `" + input[i] +
+                                           "'.");
+            }
+        }
+    }
+
+    /*
+     * Throws an exception if <code>Input</code> is
+     * <code>exceptionalInput</code> and the regular expression
+     * matches one of the strings or if <code>Input</code> is not
+     * <code>exceptionalInput</code> and the regular expression fails
+     * to match an input string.
+     */
+    private static void testRegex(String [] input, boolean exceptionalInput) {
+        /*
+         * The regex below is taken from the JavaDoc for
+         * Double.valueOf.
+         */
+
+        final String Digits     = "(\\p{Digit}+)";
+        final String HexDigits  = "(\\p{XDigit}+)";
+        // an exponent is 'e' or 'E' followed by an optionally
+        // signed decimal integer.
+        final String Exp        = "[eE][+-]?"+Digits;
+        final String fpRegex    =
+            ("[\\x00-\\x20]*"+  // Optional leading "whitespace"
+             "[+-]?(" + // Optional sign character
+             "NaN|" +           // "NaN" string
+             "Infinity|" +      // "Infinity" string
+
+             // A floating-point string representing a finite positive
+             // number without a leading sign has at most five basic pieces:
+             // Digits . Digits ExponentPart FloatTypeSuffix
+             //
+             // Since this method allows integer-only strings as input
+             // in addition to strings of floating-point literals, the
+             // two sub-patterns below are simplifications of the grammar
+             // productions from the Java Language Specification, 2nd
+             // edition, section 3.10.2.
+
+
+             // A decimal floating-point string representing a finite positive
+             // number without a leading sign has at most five basic pieces:
+             // Digits . Digits ExponentPart FloatTypeSuffix
+             //
+             // Since this method allows integer-only strings as input
+             // in addition to strings of floating-point literals, the
+             // two sub-patterns below are simplifications of the grammar
+             // productions from the Java Language Specification, 2nd
+             // edition, section 3.10.2.
+
+             // Digits ._opt Digits_opt ExponentPart_opt FloatTypeSuffix_opt
+             "(((("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+
+
+             // . Digits ExponentPart_opt FloatTypeSuffix_opt
+             "(\\.("+Digits+")("+Exp+")?))|"+
+
+            // Hexadecimal strings
+            "((" +
+             // 0[xX] HexDigits ._opt BinaryExponent FloatTypeSuffix_opt
+             "(0[xX]" + HexDigits + "(\\.)?)|" +
+
+             // 0[xX] HexDigits_opt . HexDigits BinaryExponent FloatTypeSuffix_opt
+             "(0[xX]" + HexDigits + "?(\\.)" + HexDigits + ")" +
+
+             ")[pP][+-]?" + Digits + "))" +
+             "[fFdD]?))" +
+             "[\\x00-\\x20]*");// Optional trailing "whitespace"
+        Pattern fpPattern = Pattern.compile(fpRegex);
+
+        for(int i = 0; i < input.length; i++) {
+             Matcher m = fpPattern.matcher(input[i]);
+             if (m.matches() != ! exceptionalInput) {
+                 throw new RuntimeException("Regular expression " +
+                                            (exceptionalInput?
+                                             "accepted bad":
+                                             "rejected good") +
+                                            " string `" +
+                                            input[i] + "'.");
+             }
+        }
+
+    }
+
+    public static void main(String[] args) throws Exception {
+        rudimentaryTest();
+
+        testParsing(goodStrings, false);
+        testParsing(paddedGoodStrings, false);
+        testParsing(badStrings, true);
+        testParsing(paddedBadStrings, true);
+
+        testRegex(goodStrings, false);
+        testRegex(paddedGoodStrings, false);
+        testRegex(badStrings, true);
+        testRegex(paddedBadStrings, true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Double/ParseHexFloatingPoint.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,448 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4826774
+ * @summary Numerical tests for hexadecimal inputs to parseDouble, parseFloat
+ * @author Joseph D. Darcy
+ */
+
+
+import java.util.regex.*;
+import sun.misc.FpUtils;
+import sun.misc.DoubleConsts;
+
+public class ParseHexFloatingPoint {
+    private ParseHexFloatingPoint(){}
+
+    public static final double infinityD = Double.POSITIVE_INFINITY;
+    public static final double NaND = Double.NaN;
+
+    static int test(String testName, String input,
+                    double result, double expected) {
+        int failures =0;
+
+        if (Double.compare(result, expected) != 0 ) {
+            System.err.println("Failure for " + testName +
+                               ": For input " + input +
+                               " expected " + expected +
+                               " got " + result + ".");
+        }
+
+        return failures;
+    }
+
+    static int testCase(String input, double expected) {
+        int failures =0;
+
+
+        // Try different combination of letter components
+        input = input.toLowerCase(java.util.Locale.US);
+
+        String [] suffices = {"", "f", "F", "d", "D"};
+        String [] signs = {"", "-", "+"};
+
+        for(int i = 0; i < 2; i++) {
+            String s1 = input;
+            if(i == 1)
+                s1 = s1.replace('x', 'X');
+
+            for(int j = 0; j < 2; j++) {
+                String s2 = s1;
+                if(j == 1)
+                    s2 = s2.replace('p', 'P');
+
+                for(int k = 0; k < 2; k++) {
+                    String s3 = s2;
+                    if(k == 1)
+                        s3 = upperCaseHex(s3);
+
+
+                    for(int m = 0; m < suffices.length; m++) {
+                        String s4 = s3 + suffices[m];
+
+
+                        for(int n = 0; n < signs.length; n++) {
+                            String s5 = signs[n] + s4;
+
+                            double result = Double.parseDouble(s5);
+                            failures += test("Double.parseDouble",
+                                             s5, result, (signs[n].equals("-") ?
+                                                          -expected:
+                                                          expected));
+                        }
+                    }
+                }
+            }
+        }
+
+        return failures;
+    }
+
+    static String upperCaseHex(String s) {
+        return s.replace('a', 'A').replace('b', 'B').replace('c', 'C').
+                 replace('d', 'D').replace('e','E').replace('f', 'F');
+    }
+
+    /*
+     * Test easy and tricky double rounding cases.
+     */
+    static int doubleTests() {
+
+        /*
+         * A String, double pair
+         */
+        class PairSD {
+            public String s;
+            public double d;
+            PairSD(String s, double d) {
+                this.s = s;
+                this.d = d;
+            }
+        }
+        int failures = 0;
+
+
+
+        // Hex strings that convert to three; test basic functionality
+        // of significand and exponent shift adjusts along with the
+        // no-op of adding leading zeros.  These cases don't exercise
+        // the rounding code.
+        String leadingZeros = "0x0000000000000000000";
+        String [] threeTests = {
+            "0x.003p12",
+            "0x.006p11",
+            "0x.00cp10",
+            "0x.018p9",
+
+            "0x.3p4",
+            "0x.6p3",
+            "0x.cp2",
+            "0x1.8p1",
+
+            "0x3p0",
+            "0x6.0p-1",
+            "0xc.0p-2",
+            "0x18.0p-3",
+
+            "0x3000000p-24",
+            "0x3.0p0",
+            "0x3.000000p0",
+        };
+        for(int i=0; i < threeTests.length; i++) {
+            String input = threeTests[i];
+            failures += testCase(input, 3.0);
+
+            input.replaceFirst("^0x", leadingZeros);
+            failures += testCase(input, 3.0);
+        }
+
+        long bigExponents [] = {
+            2*DoubleConsts.MAX_EXPONENT,
+            2*DoubleConsts.MIN_EXPONENT,
+
+            (long)Integer.MAX_VALUE-1,
+            (long)Integer.MAX_VALUE,
+            (long)Integer.MAX_VALUE+1,
+
+            (long)Integer.MIN_VALUE-1,
+            (long)Integer.MIN_VALUE,
+            (long)Integer.MIN_VALUE+1,
+
+            Long.MAX_VALUE-1,
+            Long.MAX_VALUE,
+
+            Long.MIN_VALUE+1,
+            Long.MIN_VALUE,
+        };
+
+        // Test zero significand with large exponents.
+        for(int i = 0; i < bigExponents.length; i++) {
+            failures += testCase("0x0.0p"+Long.toString(bigExponents[i]) , 0.0);
+        }
+
+        // Test nonzero significand with large exponents.
+        for(int i = 0; i < bigExponents.length; i++) {
+            long exponent = bigExponents[i];
+            failures += testCase("0x10000.0p"+Long.toString(exponent) ,
+                                 (exponent <0?0.0:infinityD));
+        }
+
+        // Test significands with different lengths and bit patterns.
+        {
+            long signif = 0;
+                for(int i = 1; i <= 0xe; i++) {
+                    signif = (signif <<4) | (long)i;
+                    failures += testCase("0x"+Long.toHexString(signif)+"p0", signif);
+                }
+        }
+
+        PairSD [] testCases = {
+            new PairSD("0x0.0p0",               0.0/16.0),
+            new PairSD("0x0.1p0",               1.0/16.0),
+            new PairSD("0x0.2p0",               2.0/16.0),
+            new PairSD("0x0.3p0",               3.0/16.0),
+            new PairSD("0x0.4p0",               4.0/16.0),
+            new PairSD("0x0.5p0",               5.0/16.0),
+            new PairSD("0x0.6p0",               6.0/16.0),
+            new PairSD("0x0.7p0",               7.0/16.0),
+            new PairSD("0x0.8p0",               8.0/16.0),
+            new PairSD("0x0.9p0",               9.0/16.0),
+            new PairSD("0x0.ap0",               10.0/16.0),
+            new PairSD("0x0.bp0",               11.0/16.0),
+            new PairSD("0x0.cp0",               12.0/16.0),
+            new PairSD("0x0.dp0",               13.0/16.0),
+            new PairSD("0x0.ep0",               14.0/16.0),
+            new PairSD("0x0.fp0",               15.0/16.0),
+
+            // Half-way case between zero and MIN_VALUE rounds down to
+            // zero
+            new PairSD("0x1.0p-1075",           0.0),
+
+            // Slighly more than half-way case between zero and
+            // MIN_VALUES rounds up to zero.
+            new PairSD("0x1.1p-1075",                   Double.MIN_VALUE),
+            new PairSD("0x1.000000000001p-1075",        Double.MIN_VALUE),
+            new PairSD("0x1.000000000000001p-1075",     Double.MIN_VALUE),
+
+            // More subnormal rounding tests
+            new PairSD("0x0.fffffffffffff7fffffp-1022", FpUtils.nextDown(DoubleConsts.MIN_NORMAL)),
+            new PairSD("0x0.fffffffffffff8p-1022",      DoubleConsts.MIN_NORMAL),
+            new PairSD("0x0.fffffffffffff800000001p-1022",DoubleConsts.MIN_NORMAL),
+            new PairSD("0x0.fffffffffffff80000000000000001p-1022",DoubleConsts.MIN_NORMAL),
+            new PairSD("0x1.0p-1022",                   DoubleConsts.MIN_NORMAL),
+
+
+            // Large value and overflow rounding tests
+            new PairSD("0x1.fffffffffffffp1023",        Double.MAX_VALUE),
+            new PairSD("0x1.fffffffffffff0000000p1023", Double.MAX_VALUE),
+            new PairSD("0x1.fffffffffffff4p1023",       Double.MAX_VALUE),
+            new PairSD("0x1.fffffffffffff7fffffp1023",  Double.MAX_VALUE),
+            new PairSD("0x1.fffffffffffff8p1023",       infinityD),
+            new PairSD("0x1.fffffffffffff8000001p1023", infinityD),
+
+            new PairSD("0x1.ffffffffffffep1023",        FpUtils.nextDown(Double.MAX_VALUE)),
+            new PairSD("0x1.ffffffffffffe0000p1023",    FpUtils.nextDown(Double.MAX_VALUE)),
+            new PairSD("0x1.ffffffffffffe8p1023",       FpUtils.nextDown(Double.MAX_VALUE)),
+            new PairSD("0x1.ffffffffffffe7p1023",       FpUtils.nextDown(Double.MAX_VALUE)),
+            new PairSD("0x1.ffffffffffffeffffffp1023",  Double.MAX_VALUE),
+            new PairSD("0x1.ffffffffffffe8000001p1023", Double.MAX_VALUE),
+        };
+
+        for (int i = 0; i < testCases.length; i++) {
+            failures += testCase(testCases[i].s,testCases[i].d);
+        }
+
+        failures += significandAlignmentTests();
+
+        {
+            java.util.Random rand = new java.util.Random();
+            // Consistency check; double => hexadecimal => double
+            // preserves the original value.
+            for(int i = 0; i < 1000; i++) {
+                double d = rand.nextDouble();
+                failures += testCase(Double.toHexString(d), d);
+            }
+        }
+
+        return failures;
+    }
+
+    /*
+     * Verify rounding works the same regardless of how the
+     * significand is aligned on input.  A useful extension could be
+     * to have this sort of test for strings near the overflow
+     * threshold.
+     */
+    static int significandAlignmentTests() {
+        int failures = 0;
+                // baseSignif * 2^baseExp = nextDown(2.0)
+        long [] baseSignifs = {
+            0x1ffffffffffffe00L,
+            0x1fffffffffffff00L
+        };
+
+        double [] answers = {
+            FpUtils.nextDown(FpUtils.nextDown(2.0)),
+            FpUtils.nextDown(2.0),
+            2.0
+        };
+
+        int baseExp = -60;
+        int count = 0;
+        for(int i = 0; i < 2; i++) {
+            for(long j = 0; j <= 0xfL; j++) {
+                for(long k = 0; k <= 8; k+= 4) { // k = {0, 4, 8}
+                    long base = baseSignifs[i];
+                    long testValue = base | (j<<4) | k;
+
+                    int offset = 0;
+                    // Calculate when significand should be incremented
+                    // see table 4.7 in Koren book
+
+                    if ((base & 0x100L) == 0L ) { // lsb is 0
+                        if ( (j >= 8L) &&         // round is 1
+                             ((j & 0x7L) != 0 || k != 0 ) ) // sticky is 1
+                            offset = 1;
+                    }
+                    else {                        // lsb is 1
+                        if (j >= 8L)              // round is 1
+                            offset = 1;
+                    }
+
+                    double expected = answers[i+offset];
+
+                    for(int m = -2; m <= 3; m++) {
+                        count ++;
+
+                        // Form equal value string and evaluate it
+                        String s = "0x" +
+                            Long.toHexString((m >=0) ?(testValue<<m):(testValue>>(-m))) +
+                            "p" + (baseExp - m);
+
+                        failures += testCase(s, expected);
+                    }
+                }
+            }
+        }
+
+        return failures;
+    }
+
+
+    /*
+     * Test tricky float rounding cases.  The code which
+     * reads in a hex string converts the string to a double value.
+     * If a float value is needed, the double value is cast to float.
+     * However, the cast be itself not always guaranteed to return the
+     * right result since:
+     *
+     * 1. hex string => double can discard a sticky bit which would
+     * influence a direct hex string => float conversion.
+     *
+     * 2. hex string => double => float can have a rounding to double
+     * precision which results in a larger float value while a direct
+     * hex string => float conversion would not round up.
+     *
+     * This method includes tests of the latter two possibilities.
+     */
+    static int floatTests(){
+        int failures = 0;
+
+        /*
+         * A String, float pair
+         */
+        class PairSD {
+            public String s;
+            public float f;
+            PairSD(String s, float f) {
+                this.s = s;
+                this.f = f;
+            }
+        }
+
+        String [][] roundingTestCases = {
+            // Target float value       hard rouding version
+
+            {"0x1.000000p0",    "0x1.0000000000001p0"},
+
+            // Try some values that should round up to nextUp(1.0f)
+            {"0x1.000002p0",    "0x1.0000010000001p0"},
+            {"0x1.000002p0",    "0x1.00000100000008p0"},
+            {"0x1.000002p0",    "0x1.0000010000000fp0"},
+            {"0x1.000002p0",    "0x1.00000100000001p0"},
+            {"0x1.000002p0",    "0x1.00000100000000000000000000000000000000001p0"},
+            {"0x1.000002p0",    "0x1.0000010000000fp0"},
+
+            // Potential double rounding cases
+            {"0x1.000002p0",    "0x1.000002fffffffp0"},
+            {"0x1.000002p0",    "0x1.000002fffffff8p0"},
+            {"0x1.000002p0",    "0x1.000002ffffffffp0"},
+
+            {"0x1.000002p0",    "0x1.000002ffff0ffp0"},
+            {"0x1.000002p0",    "0x1.000002ffff0ff8p0"},
+            {"0x1.000002p0",    "0x1.000002ffff0fffp0"},
+
+
+            {"0x1.000000p0",    "0x1.000000fffffffp0"},
+            {"0x1.000000p0",    "0x1.000000fffffff8p0"},
+            {"0x1.000000p0",    "0x1.000000ffffffffp0"},
+
+            {"0x1.000000p0",    "0x1.000000ffffffep0"},
+            {"0x1.000000p0",    "0x1.000000ffffffe8p0"},
+            {"0x1.000000p0",    "0x1.000000ffffffefp0"},
+
+            // Float subnormal cases
+            {"0x0.000002p-126", "0x0.0000010000001p-126"},
+            {"0x0.000002p-126", "0x0.00000100000000000001p-126"},
+
+            {"0x0.000006p-126", "0x0.0000050000001p-126"},
+            {"0x0.000006p-126", "0x0.00000500000000000001p-126"},
+
+            {"0x0.0p-149",      "0x0.7ffffffffffffffp-149"},
+            {"0x1.0p-148",      "0x1.3ffffffffffffffp-148"},
+            {"0x1.cp-147",      "0x1.bffffffffffffffp-147"},
+
+            {"0x1.fffffcp-127", "0x1.fffffdffffffffp-127"},
+        };
+
+        String [] signs = {"", "-"};
+
+        for(int i = 0; i < roundingTestCases.length; i++) {
+            for(int j = 0; j < signs.length; j++) {
+                String expectedIn = signs[j]+roundingTestCases[i][0];
+                String resultIn   = signs[j]+roundingTestCases[i][1];
+
+                float expected =  Float.parseFloat(expectedIn);
+                float result   =  Float.parseFloat(resultIn);
+
+                if( Float.compare(expected, result) != 0) {
+                    failures += 1;
+                    System.err.println("" + (i+1));
+                    System.err.println("Expected = " + Float.toHexString(expected));
+                    System.err.println("Rounded  = " + Float.toHexString(result));
+                    System.err.println("Double   = " + Double.toHexString(Double.parseDouble(resultIn)));
+                    System.err.println("Input    = " + resultIn);
+                    System.err.println("");
+                }
+            }
+        }
+
+        return failures;
+    }
+
+    public static void main(String argv[]) {
+        int failures = 0;
+
+        failures += doubleTests();
+        failures += floatTests();
+
+        if (failures != 0) {
+            throw new RuntimeException("" + failures + " failures while " +
+                                       "testing hexadecimal floating-point " +
+                                       "parsing.");
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Double/ToHexString.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,252 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4826774 4926547
+ * @summary Tests for {Float, Double}.toHexString methods
+ * @author Joseph D. Darcy
+ */
+
+import java.util.regex.*;
+import sun.misc.FpUtils;
+import sun.misc.DoubleConsts;
+
+public class ToHexString {
+    private ToHexString() {}
+
+    /*
+     * Given a double value, create a hexadecimal floating-point
+     * string via an intermediate long hex string.
+     */
+    static String doubleToHexString(double d) {
+        return hexLongStringtoHexDoubleString(Long.toHexString(Double.doubleToLongBits(d)));
+    }
+
+    /*
+     * Transform the hexadecimal long output into the equivalent
+     * hexadecimal double value.
+     */
+    static String hexLongStringtoHexDoubleString(String transString) {
+        transString = transString.toLowerCase();
+
+        String zeros = "";
+        StringBuffer result = new StringBuffer(24);
+
+        for(int i = 0; i < (16 - transString.length()); i++, zeros += "0");
+        transString = zeros + transString;
+
+        // assert transString.length == 16;
+
+            char topChar;
+            // Extract sign
+            if((topChar=transString.charAt(0)) >= '8' ) {// 8, 9, a, A, b, B, ...
+                result.append("-");
+                // clear sign bit
+                transString =
+                    Character.toString(Character.forDigit(Character.digit(topChar, 16) - 8, 16)) +
+                    transString.substring(1,16);
+            }
+
+            // check for NaN and infinity
+            String signifString = transString.substring(3,16);
+
+            if( transString.substring(0,3).equals("7ff") ) {
+                if(signifString.equals("0000000000000")) {
+                    result.append("Infinity");
+                }
+                else
+                    result.append("NaN");
+            }
+            else { // finite value
+                // Extract exponent
+                int exponent = Integer.parseInt(transString.substring(0,3), 16) -
+                    DoubleConsts.EXP_BIAS;
+                result.append("0x");
+
+                if (exponent == DoubleConsts.MIN_EXPONENT - 1) { // zero or subnormal
+                    if(signifString.equals("0000000000000")) {
+                        result.append("0.0p0");
+                    }
+                    else {
+                        result.append("0." + signifString.replaceFirst("0+$", "").replaceFirst("^$", "0") +
+                                      "p-1022");
+                    }
+                }
+                else {  // normal value
+                    result.append("1." + signifString.replaceFirst("0+$", "").replaceFirst("^$", "0") +
+                                  "p" + exponent);
+                }
+            }
+            return result.toString();
+    }
+
+    public static int toHexStringTests() {
+        int failures = 0;
+        String [][] testCases1 = {
+            {"Infinity",                "Infinity"},
+            {"-Infinity",               "-Infinity"},
+            {"NaN",                     "NaN"},
+            {"-NaN",                    "NaN"},
+            {"0.0",                     "0x0.0p0"},
+            {"-0.0",                    "-0x0.0p0"},
+            {"1.0",                     "0x1.0p0"},
+            {"-1.0",                    "-0x1.0p0"},
+            {"2.0",                     "0x1.0p1"},
+            {"3.0",                     "0x1.8p1"},
+            {"0.5",                     "0x1.0p-1"},
+            {"0.25",                    "0x1.0p-2"},
+            {"1.7976931348623157e+308", "0x1.fffffffffffffp1023"},      // MAX_VALUE
+            {"2.2250738585072014E-308", "0x1.0p-1022"},                 // MIN_NORMAL
+            {"2.225073858507201E-308",  "0x0.fffffffffffffp-1022"},     // MAX_SUBNORMAL
+            {"4.9e-324",                "0x0.0000000000001p-1022"}      // MIN_VALUE
+        };
+
+        // Compare decimal string -> double -> hex string to hex string
+        for (int i = 0; i < testCases1.length; i++) {
+            String result;
+            if(! (result=Double.toHexString(Double.parseDouble(testCases1[i][0]))).
+               equals(testCases1[i][1])) {
+                failures ++;
+                System.err.println("For floating-point string " + testCases1[i][0] +
+                                   ", expected hex output " + testCases1[i][1] + ", got " + result +".");
+            }
+        }
+
+
+        // Except for float subnormals, the output for numerically
+        // equal float and double values should be the same.
+        // Therefore, we will explicitly test float subnormal values.
+        String [][] floatTestCases = {
+            {"Infinity",                "Infinity"},
+            {"-Infinity",               "-Infinity"},
+            {"NaN",                     "NaN"},
+            {"-NaN",                    "NaN"},
+            {"0.0",                     "0x0.0p0"},
+            {"-0.0",                    "-0x0.0p0"},
+            {"1.0",                     "0x1.0p0"},
+            {"-1.0",                    "-0x1.0p0"},
+            {"2.0",                     "0x1.0p1"},
+            {"3.0",                     "0x1.8p1"},
+            {"0.5",                     "0x1.0p-1"},
+            {"0.25",                    "0x1.0p-2"},
+            {"3.4028235e+38f",          "0x1.fffffep127"},      // MAX_VALUE
+            {"1.17549435E-38f",         "0x1.0p-126"},          // MIN_NORMAL
+            {"1.1754942E-38",           "0x0.fffffep-126"},     // MAX_SUBNORMAL
+            {"1.4e-45f",                "0x0.000002p-126"}      // MIN_VALUE
+        };
+        // Compare decimal string -> double -> hex string to hex string
+        for (int i = 0; i < floatTestCases.length; i++) {
+            String result;
+            if(! (result=Float.toHexString(Float.parseFloat(floatTestCases[i][0]))).
+               equals(floatTestCases[i][1])) {
+                failures++;
+                System.err.println("For floating-point string " + floatTestCases[i][0] +
+                                   ", expected hex output\n" + floatTestCases[i][1] + ", got\n" + result +".");
+            }
+        }
+
+        // Particular floating-point values and hex equivalents, mostly
+        // taken from fdlibm source.
+        String [][] testCases2 = {
+            {"+0.0",                                    "0000000000000000"},
+            {"-0.0",                                    "8000000000000000"},
+            {"+4.9e-324",                               "0000000000000001"},
+            {"-4.9e-324",                               "8000000000000001"},
+
+            // fdlibm k_sin.c
+            {"+5.00000000000000000000e-01",             "3FE0000000000000"},
+            {"-1.66666666666666324348e-01",             "BFC5555555555549"},
+            {"+8.33333333332248946124e-03",             "3F8111111110F8A6"},
+            {"-1.98412698298579493134e-04",             "BF2A01A019C161D5"},
+            {"+2.75573137070700676789e-06",             "3EC71DE357B1FE7D"},
+            {"-2.50507602534068634195e-08",             "BE5AE5E68A2B9CEB"},
+            {"+1.58969099521155010221e-10",             "3DE5D93A5ACFD57C"},
+
+            // fdlibm k_cos.c
+            {"+4.16666666666666019037e-02",             "3FA555555555554C"},
+            {"-1.38888888888741095749e-03",             "BF56C16C16C15177"},
+            {"+2.48015872894767294178e-05",             "3EFA01A019CB1590"},
+            {"-2.75573143513906633035e-07",             "BE927E4F809C52AD"},
+            {"+2.08757232129817482790e-09",             "3E21EE9EBDB4B1C4"},
+            {"-1.13596475577881948265e-11",             "BDA8FAE9BE8838D4"},
+
+            // fdlibm e_rempio.c
+            {"1.67772160000000000000e+07",              "4170000000000000"},
+            {"6.36619772367581382433e-01",              "3FE45F306DC9C883"},
+            {"1.57079632673412561417e+00",              "3FF921FB54400000"},
+            {"6.07710050650619224932e-11",              "3DD0B4611A626331"},
+            {"6.07710050630396597660e-11",              "3DD0B4611A600000"},
+            {"2.02226624879595063154e-21",              "3BA3198A2E037073"},
+            {"2.02226624871116645580e-21",              "3BA3198A2E000000"},
+            {"8.47842766036889956997e-32",              "397B839A252049C1"},
+
+
+            // fdlibm s_cbrt.c
+            {"+5.42857142857142815906e-01",             "3FE15F15F15F15F1"},
+            {"-7.05306122448979611050e-01",             "BFE691DE2532C834"},
+            {"+1.41428571428571436819e+00",             "3FF6A0EA0EA0EA0F"},
+            {"+1.60714285714285720630e+00",             "3FF9B6DB6DB6DB6E"},
+            {"+3.57142857142857150787e-01",             "3FD6DB6DB6DB6DB7"},
+        };
+
+        // Compare decimal string -> double -> hex string to
+        // long hex string -> double hex string
+        for (int i = 0; i < testCases2.length; i++) {
+            String result;
+            String expected;
+            if(! (result=Double.toHexString(Double.parseDouble(testCases2[i][0]))).
+               equals( expected=hexLongStringtoHexDoubleString(testCases2[i][1]) )) {
+                failures ++;
+                System.err.println("For floating-point string " + testCases2[i][0] +
+                                   ", expected hex output " + expected + ", got " + result +".");
+            }
+        }
+
+        // Test random double values;
+        // compare double -> Double.toHexString with local doubleToHexString
+        java.util.Random rand = new java.util.Random(0);
+        for (int i = 0; i < 1000; i++) {
+            String result;
+            String expected;
+            double d = rand.nextDouble();
+            if(! (expected=doubleToHexString(d)).equals(result=Double.toHexString(d)) ) {
+                failures ++;
+                System.err.println("For floating-point value " + d +
+                                   ", expected hex output " + expected + ", got " + result +".");
+            }
+        }
+
+        return failures;
+    }
+
+    public static void main(String argv[]) {
+        int failures = 0;
+
+        failures = toHexStringTests();
+
+        if (failures != 0) {
+            throw new RuntimeException("" + failures + " failures while testing Double.toHexString");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Float/BitwiseConversion.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 5037596
+ * @summary Verify bitwise conversion works for non-canonical NaN values
+ * @author Joseph D. Darcy
+ */
+
+import static java.lang.Float.*;
+import static sun.misc.FloatConsts.*;
+
+public class BitwiseConversion {
+    static int testNanCase(int x) {
+        int errors  = 0;
+        // Strip out sign and exponent bits
+        int y = x & SIGNIF_BIT_MASK;
+
+        float values[] = {
+            intBitsToFloat(EXP_BIT_MASK | y),
+            intBitsToFloat(SIGN_BIT_MASK | EXP_BIT_MASK | y)
+        };
+
+        for(float value: values) {
+            if (!isNaN(value)) {
+                throw new RuntimeException("Invalid input " + y +
+                                           "yielded non-NaN" + value);
+            }
+            int converted = floatToIntBits(value);
+            if (converted != 0x7fc00000) {
+                errors++;
+                System.err.format("Non-canoncial NaN bits returned: %x%n",
+                                  converted);
+            }
+        }
+        return errors;
+    }
+
+    public static void main(String... argv) {
+        int errors = 0;
+
+        for (int i = 0; i < SIGNIFICAND_WIDTH-1; i++) {
+            errors += testNanCase(1<<i);
+        }
+
+        if (floatToIntBits(Float.POSITIVE_INFINITY)
+                != 0x7F800000) {
+            errors++;
+            System.err.println("Bad conversion for +infinity.");
+        }
+
+        if (floatToIntBits(Float.NEGATIVE_INFINITY)
+                != 0xFF800000) {
+            errors++;
+            System.err.println("Bad conversion for -infinity.");
+        }
+
+        if (errors > 0)
+            throw new RuntimeException();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Float/Constants.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2001-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @compile Constants.java
+ * @bug 4397405 4826652
+ * @summary Testing constant-ness of Float.{MIN_VALUE, MAX_VALUE}, etc.
+ * @author Joseph D. Darcy
+ */
+
+public class Constants {
+    /*
+     * This compile-only test is to make sure that the primitive
+     * public static final fields in java.lang.Float are "constant
+     * expressions" as defined by "The Java Language Specification,
+     * 2nd edition" section 15.28; a different test checks the values
+     * of those fields.
+     */
+    public static void main(String[] args) throws Exception {
+        int i = 0;
+        switch (i) {
+        case (int)Float.NaN:                    // 0
+            System.out.println("Float.NaN is a constant!");
+            break;
+        case (int)Float.MIN_VALUE + 1:          // 0 + 1
+            System.out.println("Float.MIN_VALUE is a constant!");
+            break;
+        case (int)Float.MIN_NORMAL + 2:         // 0 + 2
+            System.out.println("Float.MIN_NORMAL is a constant!");
+            break;
+        case Float.MIN_EXPONENT:                // -126
+            System.out.println("Float.MIN_EXPONENT is a constant!");
+            break;
+        case Float.MAX_EXPONENT:                // 127
+            System.out.println("Float.MAX_EXPONENT is a constant!");
+            break;
+        case (int)Float.MAX_VALUE - 1:          // Integer.MAX_VALUE - 1
+            System.out.println("Float.MAX_VALUE is a constant!");
+            break;
+        case (int)Float.POSITIVE_INFINITY:      // Integer.MAX_VALUE
+            System.out.println("Float.POSITIVE_INFINITY is a constant!");
+            break;
+        case (int)Float.NEGATIVE_INFINITY:      // Integer.MIN_VALUE
+            System.out.println("Float.NEGATIVE_INFINITY is a constant!");
+            break;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Float/Extrema.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2001-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4408489 4826652
+ * @summary Testing values of Float.{MIN_VALUE, MIN_NORMAL, MAX_VALUE}
+ * @author Joseph D. Darcy
+ */
+
+public class Extrema {
+    public static void main(String[] args) throws Exception {
+        if (Float.MIN_VALUE != Float.intBitsToFloat(0x1))
+            throw new RuntimeException("Float.MIN_VALUE is not equal "+
+                                       "to intBitsToFloat(0x1).");
+
+        if (Float.MIN_NORMAL != Float.intBitsToFloat(0x00800000))
+            throw new RuntimeException("Float.MIN_NORMAL is not equal "+
+                                       "to intBitsToFloat(0x00800000).");
+
+        if (Float.MAX_VALUE != Float.intBitsToFloat(0x7f7fffff))
+            throw new RuntimeException("Float.MAX_VALUE is not equal "+
+                                       "to intBitsToFloat(0x7f7fffff).");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Float/NaNInfinityParsing.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2001 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4428772
+ * @summary Testing recognition of "NaN" and "Infinity" strings
+ * @author Joseph D. Darcy
+ */
+
+
+public class NaNInfinityParsing {
+    /*
+     * Regression tests for:
+     * 4428772 -- Establish invariant for Float & Double classes and
+     * their string representations
+     *
+     * Added capability for parse{Float, Double} and related methods
+     * to recognize "NaN" and "Infinity" strings so that
+     * parseFloat(toString(d)) will always return the original
+     * floating-point value.
+     */
+
+    static String NaNStrings[] = {
+        "NaN",
+        "+NaN",
+        "-NaN"
+    };
+
+    static String infinityStrings[] = {
+        "Infinity",
+        "+Infinity",
+        "-Infinity",
+    };
+
+    static String invalidStrings[] = {
+        "+",
+        "-",
+        "@",
+        "N",
+        "Na",
+        "Nan",
+        "NaNf",
+        "NaNd",
+        "NaNF",
+        "NaND",
+        "+N",
+        "+Na",
+        "+Nan",
+        "+NaNf",
+        "+NaNd",
+        "+NaNF",
+        "+NaND",
+        "-N",
+        "-Na",
+        "-Nan",
+        "-NaNf",
+        "-NaNd",
+        "-NaNF",
+        "-NaND",
+        "I",
+        "In",
+        "Inf",
+        "Infi",
+        "Infin",
+        "Infini",
+        "Infinit",
+        "InfinitY",
+        "Infinityf",
+        "InfinityF",
+        "Infinityd",
+        "InfinityD",
+        "+I",
+        "+In",
+        "+Inf",
+        "+Infi",
+        "+Infin",
+        "+Infini",
+        "+Infinit",
+        "+InfinitY",
+        "+Infinityf",
+        "+InfinityF",
+        "+Infinityd",
+        "+InfinityD",
+        "-I",
+        "-In",
+        "-Inf",
+        "-Infi",
+        "-Infin",
+        "-Infini",
+        "-Infinit",
+        "-InfinitY",
+        "-Infinityf",
+        "-InfinityF",
+        "-Infinityd",
+        "-InfinityD",
+        "NaNInfinity",
+        "InfinityNaN",
+        "nan",
+        "infinity"
+    };
+
+    public static void main(String [] argv) throws Exception {
+        int i;
+        float d;
+
+        // Test valid NaN strings
+        for(i = 0; i < NaNStrings.length; i++) {
+            if(!Float.isNaN(d=Float.parseFloat(NaNStrings[i]))) {
+                throw new RuntimeException("NaN string ``" + NaNStrings[i]
+                                           + "'' did not parse as a NaN; returned " +
+                                           d + " instead.");
+            }
+        }
+
+        // Test valid Infinity strings
+        for(i = 0; i < infinityStrings.length; i++) {
+            if(!Float.isInfinite(d=Float.parseFloat(infinityStrings[i]))) {
+                throw new RuntimeException("Infinity string ``" +
+                                           infinityStrings[i] +
+                                           "'' did not parse as infinity; returned " +
+                                           d + "instead.");
+            }
+            // check sign of result
+
+            boolean negative = (infinityStrings[i].charAt(0) == '-');
+            if(d != (negative?Float.NEGATIVE_INFINITY:
+                          Float.POSITIVE_INFINITY))
+                throw new RuntimeException("Infinity has wrong sign;" +
+                                           (negative?"positive instead of negative.":
+                                            "negative instead of positive."));
+        }
+
+        // Test almost valid strings
+        for(i = 0; i < invalidStrings.length; i++) {
+            try {
+                float result;
+                d = Float.parseFloat(invalidStrings[i]);
+                throw new RuntimeException("Invalid string ``" +
+                                           invalidStrings[i]
+                                           +"'' parsed as " + d + ".");
+            }
+            catch(NumberFormatException e) {
+                // expected
+            }
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Float/ParseFloat.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,210 @@
+/*
+ * Copyright 1998-2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4160406 4705734 4707389
+ * @summary Tests for Float.parseFloat method
+ */
+
+public class ParseFloat {
+
+    private static void check(String val, float expected) {
+        float n = Float.parseFloat(val);
+        if (n != expected)
+            throw new RuntimeException("Float.parseFloat failed. String:" +
+                                                val + " Result:" + n);
+    }
+
+    private static void rudimentaryTest() {
+        check(new String(""+Float.MIN_VALUE), Float.MIN_VALUE);
+        check(new String(""+Float.MAX_VALUE), Float.MAX_VALUE);
+
+        check("10",     (float)  10.0);
+        check("10.0",   (float)  10.0);
+        check("10.01",  (float)  10.01);
+
+        check("-10",    (float) -10.0);
+        check("-10.00", (float) -10.0);
+        check("-10.01", (float) -10.01);
+    }
+
+    static  String badStrings[] = {
+        "",
+        "+",
+        "-",
+        "+e",
+        "-e",
+        "+e170",
+        "-e170",
+
+        // Make sure intermediate white space is not deleted.
+        "1234   e10",
+        "-1234   e10",
+
+        // Control characters in the interior of a string are not legal
+        "1\u0007e1",
+        "1e\u00071",
+
+        // NaN and infinity can't have trailing type suffices or exponents
+        "NaNf",
+        "NaNF",
+        "NaNd",
+        "NaND",
+        "-NaNf",
+        "-NaNF",
+        "-NaNd",
+        "-NaND",
+        "+NaNf",
+        "+NaNF",
+        "+NaNd",
+        "+NaND",
+        "Infinityf",
+        "InfinityF",
+        "Infinityd",
+        "InfinityD",
+        "-Infinityf",
+        "-InfinityF",
+        "-Infinityd",
+        "-InfinityD",
+        "+Infinityf",
+        "+InfinityF",
+        "+Infinityd",
+        "+InfinityD",
+
+        "NaNe10",
+        "-NaNe10",
+        "+NaNe10",
+        "Infinitye10",
+        "-Infinitye10",
+        "+Infinitye10",
+
+        // Non-ASCII digits are not recognized
+        "\u0661e\u0661", // 1e1 in Arabic-Indic digits
+        "\u06F1e\u06F1", // 1e1 in Extended Arabic-Indic digits
+        "\u0967e\u0967" // 1e1 in Devanagari digits
+    };
+
+    static String goodStrings[] = {
+        "NaN",
+        "+NaN",
+        "-NaN",
+        "Infinity",
+        "+Infinity",
+        "-Infinity",
+        "1.1e-23f",
+        ".1e-23f",
+        "1e-23",
+        "1f",
+        "1",
+        "2",
+        "1234",
+        "-1234",
+        "+1234",
+        "2147483647",   // Integer.MAX_VALUE
+        "2147483648",
+        "-2147483648",  // Integer.MIN_VALUE
+        "-2147483649",
+
+        "16777215",
+        "16777216",     // 2^24
+        "16777217",
+
+        "-16777215",
+        "-16777216",    // -2^24
+        "-16777217",
+
+        "9007199254740991",
+        "9007199254740992",     // 2^53
+        "9007199254740993",
+
+        "-9007199254740991",
+        "-9007199254740992",    // -2^53
+        "-9007199254740993",
+
+        "9223372036854775807",
+        "9223372036854775808",  // Long.MAX_VALUE
+        "9223372036854775809",
+
+        "-9223372036854775808",
+        "-9223372036854775809", // Long.MIN_VALUE
+        "-9223372036854775810"
+    };
+
+    static String paddedBadStrings[];
+    static String paddedGoodStrings[];
+    static {
+        String pad = " \t\n\r\f\u0001\u000b\u001f";
+        paddedBadStrings = new String[badStrings.length];
+        for(int i = 0 ; i <  badStrings.length; i++)
+            paddedBadStrings[i] = pad + badStrings[i] + pad;
+
+        paddedGoodStrings = new String[goodStrings.length];
+        for(int i = 0 ; i <  goodStrings.length; i++)
+            paddedGoodStrings[i] = pad + goodStrings[i] + pad;
+
+    }
+
+    /*
+     * Throws an exception if <code>Input</code> is
+     * <code>exceptionalInput</code> and {@link Float.parseFloat
+     * parseFloat} does <em>not</em> throw an exception or if
+     * <code>Input</code> is not <code>exceptionalInput</code> and
+     * <code>parseFloat</code> throws an exception.  This method does
+     * not attempt to test whether the string is converted to the
+     * proper value; just whether the input is accepted appropriately
+     * or not.
+     */
+    private static void testParsing(String [] input,
+                                    boolean exceptionalInput) {
+        for(int i = 0; i < input.length; i++) {
+            double d;
+
+            try {
+                d = Float.parseFloat(input[i]);
+            }
+            catch (NumberFormatException e) {
+                if (! exceptionalInput) {
+                    throw new RuntimeException("Float.parseFloat rejected " +
+                                               "good string `" + input[i] +
+                                               "'.");
+                }
+                break;
+            }
+            if (exceptionalInput) {
+                throw new RuntimeException("Float.parseFloat accepted " +
+                                           "bad string `" + input[i] +
+                                           "'.");
+            }
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        rudimentaryTest();
+
+        testParsing(goodStrings, false);
+        testParsing(paddedGoodStrings, false);
+        testParsing(badStrings, true);
+        testParsing(paddedBadStrings, true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Integer/BitTwiddle.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     4495754
+ * @summary Basic test for int bit twiddling
+ * @author  Josh Bloch
+ *
+ * @compile -source 1.5 BitTwiddle.java
+ * @run main BitTwiddle
+ */
+
+import java.util.Random;
+import static java.lang.Integer.*;
+
+public class BitTwiddle {
+    private static final int N = 1000; // # of repetitions per test
+
+    public static void main(String args[]) {
+        Random rnd = new Random();
+
+        if (highestOneBit(0) != 0)
+            throw new RuntimeException("a");
+        if (highestOneBit(-1) != MIN_VALUE)
+            throw new RuntimeException("b");
+        if (highestOneBit(1) != 1)
+            throw new RuntimeException("c");
+
+        if (lowestOneBit(0) != 0)
+            throw new RuntimeException("d");
+        if (lowestOneBit(-1) != 1)
+            throw new RuntimeException("e");
+        if (lowestOneBit(MIN_VALUE) != MIN_VALUE)
+            throw new RuntimeException("f");
+
+        for (int i = 0; i < N; i++) {
+            int x = rnd.nextInt();
+            if (highestOneBit(x) != reverse(lowestOneBit(reverse(x))))
+                throw new RuntimeException("g: " + toHexString(x));
+        }
+
+        if (numberOfLeadingZeros(0) != SIZE)
+            throw new RuntimeException("h");
+        if (numberOfLeadingZeros(-1) != 0)
+            throw new RuntimeException("i");
+        if (numberOfLeadingZeros(1) != (SIZE - 1))
+            throw new RuntimeException("j");
+
+        if (numberOfTrailingZeros(0) != SIZE)
+            throw new RuntimeException("k");
+        if (numberOfTrailingZeros(1) != 0)
+            throw new RuntimeException("l");
+        if (numberOfTrailingZeros(MIN_VALUE) != (SIZE - 1))
+            throw new RuntimeException("m");
+
+        for (int i = 0; i < N; i++) {
+            int x = rnd.nextInt();
+            if (numberOfLeadingZeros(x) != numberOfTrailingZeros(reverse(x)))
+                throw new RuntimeException("n: " + toHexString(x));
+        }
+
+        if (bitCount(0) != 0)
+                throw new RuntimeException("o");
+
+        for (int i = 0; i < SIZE; i++) {
+            int pow2 = 1 << i;
+            if (bitCount(pow2) != 1)
+                throw new RuntimeException("p: " + i);
+            if (bitCount(pow2 -1) != i)
+                throw new RuntimeException("q: " + i);
+        }
+
+        for (int i = 0; i < N; i++) {
+            int x = rnd.nextInt();
+            if (bitCount(x) != bitCount(reverse(x)))
+                throw new RuntimeException("r: " + toHexString(x));
+        }
+
+        for (int i = 0; i < N; i++) {
+            int x = rnd.nextInt();
+            int dist = rnd.nextInt();
+            if (bitCount(x) != bitCount(rotateRight(x, dist)))
+                throw new RuntimeException("s: " + toHexString(x) +
+                                           toHexString(dist));
+            if (bitCount(x) != bitCount(rotateLeft(x, dist)))
+                throw new RuntimeException("t: " + toHexString(x) +
+                                           toHexString(dist));
+            if (rotateRight(x, dist) != rotateLeft(x, -dist))
+                throw new RuntimeException("u: " + toHexString(x) +
+                                           toHexString(dist));
+            if (rotateRight(x, -dist) != rotateLeft(x, dist))
+                throw new RuntimeException("v: " + toHexString(x) +
+                                           toHexString(dist));
+        }
+
+        if (signum(0) != 0 || signum(1) != 1 || signum(-1) != -1
+            || signum(MIN_VALUE) != -1 || signum(MAX_VALUE) != 1)
+            throw new RuntimeException("w");
+
+        for (int i = 0; i < N; i++) {
+            int x = rnd.nextInt();
+            int sign = (x < 0 ? -1 : (x == 0 ? 0 : 1));
+            if (signum(x) != sign)
+                throw new RuntimeException("x: " + toHexString(x));
+        }
+
+        if(reverseBytes(0xaabbccdd) != 0xddccbbaa)
+            throw new RuntimeException("y");
+
+        for (int i = 0; i < N; i++) {
+            int x = rnd.nextInt();
+            if (bitCount(x) != bitCount(reverseBytes(x)))
+                throw new RuntimeException("z: " + toHexString(x));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Integer/Decode.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4136371 5017980 6576055
+ * @summary Test Integer.decode method
+ * @author madbot
+ * @author Joseph D. Darcy
+ */
+
+/**
+ * There are six methods in java.lang.Integer which transform strings
+ * into an int or Integer value:
+ *
+ * public Integer(String s)
+ * public static Integer decode(String nm)
+ * public static int parseInteger(String s, int radix)
+ * public static int parseInteger(String s)
+ * public static Integer valueOf(String s, int radix)
+ * public static Integer valueOf(String s)
+ *
+ * The other five methods are tested elsewhere.
+ */
+public class Decode {
+
+    private static void check(String val, int expected) {
+        int n = (Integer.decode(val)).intValue();
+        if (n != expected)
+            throw new RuntimeException("Integer.decode failed. String:" +
+                                                val + " Result:" + n);
+    }
+
+    private static void checkFailure(String val, String message) {
+        try {
+            int n = (Integer.decode(val)).intValue();
+            throw new RuntimeException(message);
+        } catch (NumberFormatException e) { /* Okay */}
+    }
+
+    public static void main(String[] args) throws Exception {
+        check(new String(""+Integer.MIN_VALUE), Integer.MIN_VALUE);
+        check(new String(""+Integer.MAX_VALUE), Integer.MAX_VALUE);
+
+        check("10",   10);
+        check("0x10", 16);
+        check("0X10", 16);
+        check("010",  8);
+        check("#10",  16);
+
+        check("+10",   10);
+        check("+0x10", 16);
+        check("+0X10", 16);
+        check("+010",  8);
+        check("+#10",  16);
+
+        check("-10",   -10);
+        check("-0x10", -16);
+        check("-0X10", -16);
+        check("-010",  -8);
+        check("-#10",  -16);
+
+        check(Long.toString(Integer.MIN_VALUE), Integer.MIN_VALUE);
+        check(Long.toString(Integer.MAX_VALUE), Integer.MAX_VALUE);
+
+        checkFailure("0x-10",   "Integer.decode allows negative sign in wrong position.");
+        checkFailure("0x+10",   "Integer.decode allows positive sign in wrong position.");
+
+        checkFailure("+",       "Raw plus sign allowed.");
+        checkFailure("-",       "Raw minus sign allowed.");
+
+        checkFailure(Long.toString((long)Integer.MIN_VALUE - 1L), "Out of range");
+        checkFailure(Long.toString((long)Integer.MAX_VALUE + 1L), "Out of range");
+
+        checkFailure("", "Empty String");
+
+        try {
+            Integer.decode(null);
+            throw new RuntimeException("Integer.decode(null) expected to throw NPE");
+        } catch (NullPointerException npe) {/* Okay */}
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Integer/GetInteger.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright 1999 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4252315
+ * @summary test Integer.getInteger method with empty key
+ */
+
+public class GetInteger {
+    public static void main(String[] args) throws Exception {
+        Integer.getInteger("", 1);
+        Integer.getInteger(null, 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Integer/ParsingTest.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2006-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 5017980 6576055
+ * @summary Test parsing methods
+ * @author Joseph D. Darcy
+ */
+
+
+/**
+ * There are six methods in java.lang.Integer which transform strings
+ * into an int or Integer value:
+ *
+ * public Integer(String s)
+ * public static Integer decode(String nm)
+ * public static int parseInt(String s, int radix)
+ * public static int parseInt(String s)
+ * public static Integer valueOf(String s, int radix)
+ * public static Integer valueOf(String s)
+ *
+ * Besides decode, all the methods and constructor call down into
+ * parseInt(String, int) to do the actual work.  Therefore, the
+ * behavior of parseInt(String, int) will be tested here.
+ */
+
+public class ParsingTest {
+    public static void main(String... argv) {
+        check("+100", +100);
+        check("-100", -100);
+
+        check("+0", 0);
+        check("-0", 0);
+        check("+00000", 0);
+        check("-00000", 0);
+
+        check("0", 0);
+        check("1", 1);
+        check("9", 9);
+
+        checkFailure("\u0000");
+        checkFailure("\u002f");
+        checkFailure("+");
+        checkFailure("-");
+        checkFailure("++");
+        checkFailure("+-");
+        checkFailure("-+");
+        checkFailure("--");
+        checkFailure("++100");
+        checkFailure("--100");
+        checkFailure("+-6");
+        checkFailure("-+6");
+        checkFailure("*100");
+    }
+
+    private static void check(String val, int expected) {
+        int n = Integer.parseInt(val);
+        if (n != expected)
+            throw new RuntimeException("Integer.parsedInt failed. String:" +
+                                                val + " Result:" + n);
+    }
+
+    private static void checkFailure(String val) {
+        int n = 0;
+        try {
+            n = Integer.parseInt(val);
+            System.err.println("parseInt(" + val + ") incorrectly returned " + n);
+            throw new RuntimeException();
+        } catch (NumberFormatException nfe) {
+            ; // Expected
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Long/BitTwiddle.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     4495754
+ * @summary Basic test for long bit twiddling
+ * @author  Josh Bloch
+ *
+ * @compile -source 1.5 BitTwiddle.java
+ * @run main BitTwiddle
+ */
+
+import java.util.Random;
+import static java.lang.Long.*;
+
+public class BitTwiddle {
+    private static final int N = 1000; // # of repetitions per test
+
+    public static void main(String args[]) {
+        Random rnd = new Random();
+
+        if (highestOneBit(0) != 0)
+            throw new RuntimeException("a");
+        if (highestOneBit(-1) != MIN_VALUE)
+            throw new RuntimeException("b");
+        if (highestOneBit(1) != 1)
+            throw new RuntimeException("c");
+
+        if (lowestOneBit(0) != 0)
+            throw new RuntimeException("d");
+        if (lowestOneBit(-1) != 1)
+            throw new RuntimeException("e");
+        if (lowestOneBit(MIN_VALUE) != MIN_VALUE)
+            throw new RuntimeException("f");
+
+        for (int i = 0; i < N; i++) {
+            long x = rnd.nextLong();
+            if (highestOneBit(x) != reverse(lowestOneBit(reverse(x))))
+                throw new RuntimeException("g: " + toHexString(x));
+        }
+
+        if (numberOfLeadingZeros(0) != SIZE)
+            throw new RuntimeException("h");
+        if (numberOfLeadingZeros(-1) != 0)
+            throw new RuntimeException("i");
+        if (numberOfLeadingZeros(1) != (SIZE - 1))
+            throw new RuntimeException("j");
+
+        if (numberOfTrailingZeros(0) != SIZE)
+            throw new RuntimeException("k");
+        if (numberOfTrailingZeros(1) != 0)
+            throw new RuntimeException("l");
+        if (numberOfTrailingZeros(MIN_VALUE) != (SIZE - 1))
+            throw new RuntimeException("m");
+
+        for (int i = 0; i < N; i++) {
+            long x = rnd.nextLong();
+            if (numberOfLeadingZeros(x) != numberOfTrailingZeros(reverse(x)))
+                throw new RuntimeException("n: " + toHexString(x));
+        }
+
+        if (bitCount(0) != 0)
+                throw new RuntimeException("o");
+
+        for (int i = 0; i < SIZE; i++) {
+            long pow2 = 1L << i;
+            if (bitCount(pow2) != 1)
+                throw new RuntimeException("p: " + i);
+            if (bitCount(pow2 -1) != i)
+                throw new RuntimeException("q: " + i);
+        }
+
+        for (int i = 0; i < N; i++) {
+            long x = rnd.nextLong();
+            if (bitCount(x) != bitCount(reverse(x)))
+                throw new RuntimeException("r: " + toHexString(x));
+        }
+
+        for (int i = 0; i < N; i++) {
+            long x = rnd.nextLong();
+            int dist = rnd.nextInt();
+            if (bitCount(x) != bitCount(rotateRight(x, dist)))
+                throw new RuntimeException("s: " + toHexString(x) +
+                                           toHexString(dist));
+            if (bitCount(x) != bitCount(rotateLeft(x, dist)))
+                throw new RuntimeException("t: " + toHexString(x) +
+                                           toHexString(dist));
+            if (rotateRight(x, dist) != rotateLeft(x, -dist))
+                throw new RuntimeException("u: " + toHexString(x) +
+                                           toHexString(dist));
+            if (rotateRight(x, -dist) != rotateLeft(x, dist))
+                throw new RuntimeException("v: " + toHexString(x) +
+                                           toHexString(dist));
+        }
+
+        if (signum(0) != 0 || signum(1) != 1 || signum(-1) != -1
+            || signum(MIN_VALUE) != -1 || signum(MAX_VALUE) != 1)
+            throw new RuntimeException("w");
+
+        for (int i = 0; i < N; i++) {
+            long x = rnd.nextLong();
+            int sign = (x < 0 ? -1 : (x == 0 ? 0 : 1));
+            if (signum(x) != sign)
+                throw new RuntimeException("x: " + toHexString(x));
+        }
+
+        if(reverseBytes(0xaabbccdd11223344L) != 0x44332211ddccbbaaL)
+            throw new RuntimeException("y");
+
+        for (int i = 0; i < N; i++) {
+            long x = rnd.nextLong();
+            if (bitCount(x) != bitCount(reverseBytes(x)))
+                throw new RuntimeException("z: " + toHexString(x));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Long/Decode.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,106 @@
+/*
+ * Copyright 1998-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4136371 5017980 6576055
+ * @summary Test Long.decode method
+ * @author madbot
+ * @author Joseph D. Darcy
+ */
+
+import java.math.BigInteger;
+
+/**
+ * There are six methods in java.lang.Integer which transform strings
+ * into a long or Long value:
+ *
+ * public Long(String s)
+ * public static Long decode(String nm)
+ * public static long parseLong(String s, int radix)
+ * public static long parseLong(String s)
+ * public static Long valueOf(String s, int radix)
+ * public static Long valueOf(String s)
+ *
+ * The other five methods are tested elsewhere.
+ */
+public class Decode {
+
+    private static void check(String val, long expected) {
+        long n = (Long.decode(val)).longValue();
+        if (n != expected)
+            throw new RuntimeException("Long.decode failed. String:" +
+                                                val + " Result:" + n);
+    }
+
+    private static void checkFailure(String val, String message) {
+        try {
+            long n = (Long.decode(val)).longValue();
+            throw new RuntimeException(message);
+        } catch (NumberFormatException e) { /* Okay */}
+    }
+
+    public static void main(String[] args) throws Exception {
+        check(new String(""+Long.MIN_VALUE), Long.MIN_VALUE);
+        check(new String(""+Long.MAX_VALUE), Long.MAX_VALUE);
+
+        check("10",   10L);
+        check("0x10", 16L);
+        check("0X10", 16L);
+        check("010",  8L);
+        check("#10",  16L);
+
+        check("+10",   10L);
+        check("+0x10", 16L);
+        check("+0X10", 16L);
+        check("+010",  8L);
+        check("+#10",  16L);
+
+        check("-10",   -10L);
+        check("-0x10", -16L);
+        check("-0X10", -16L);
+        check("-010",  -8L);
+        check("-#10",  -16L);
+
+        check(Long.toString(Long.MIN_VALUE), Long.MIN_VALUE);
+        check(Long.toString(Long.MAX_VALUE), Long.MAX_VALUE);
+
+        checkFailure("0x-10",   "Long.decode allows negative sign in wrong position.");
+        checkFailure("0x+10",   "Long.decode allows positive sign in wrong position.");
+
+        checkFailure("+",       "Raw plus sign allowed.");
+        checkFailure("-",       "Raw minus sign allowed.");
+
+        checkFailure(BigInteger.valueOf(Long.MIN_VALUE).subtract(BigInteger.ONE).toString(),
+                     "Out of range");
+        checkFailure(BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.ONE).toString(),
+                     "Out of range");
+
+        checkFailure("", "Empty String");
+
+        try {
+            Long.decode(null);
+            throw new RuntimeException("Long.decode(null) expected to throw NPE");
+        } catch (NullPointerException npe) {/* Okay */}
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Long/GetLong.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright 1999 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4252322
+ * @summary test Long.getLong method with empty key
+ */
+
+public class GetLong {
+    public static void main(String[] args) throws Exception {
+        Long.getLong("", 1);
+        Long.getLong(null, 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Long/ParsingTest.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2006-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 5017980 6576055
+ * @summary Test parsing methods
+ * @author Joseph D. Darcy
+ */
+
+
+/**
+ * There are six methods in java.lang.Long which transform strings
+ * into a long or Long value:
+ *
+ * public Long(String s)
+ * public static Long decode(String nm)
+ * public static long parseLong(String s, int radix)
+ * public static long parseLong(String s)
+ * public static Long valueOf(String s, int radix)
+ * public static Long valueOf(String s)
+ *
+ * Besides decode, all the methods and constructor call down into
+ * parseLong(String, int) to do the actual work.  Therefore, the
+ * behavior of parseLong(String, int) will be tested here.
+ */
+
+public class ParsingTest {
+    public static void main(String... argv) {
+        check("+100", +100L);
+        check("-100", -100L);
+
+        check("+0", 0L);
+        check("-0", 0L);
+        check("+00000", 0L);
+        check("-00000", 0L);
+
+        check("0", 0L);
+        check("1", 1L);
+        check("9", 9L);
+
+        checkFailure("\u0000");
+        checkFailure("\u002f");
+        checkFailure("+");
+        checkFailure("-");
+        checkFailure("++");
+        checkFailure("+-");
+        checkFailure("-+");
+        checkFailure("--");
+        checkFailure("++100");
+        checkFailure("--100");
+        checkFailure("+-6");
+        checkFailure("-+6");
+        checkFailure("*100");
+    }
+
+    private static void check(String val, long expected) {
+        long n = Long.parseLong(val);
+        if (n != expected)
+            throw new RuntimeException("Long.parsedLong failed. String:" +
+                                       val + " Result:" + n);
+    }
+
+    private static void checkFailure(String val) {
+        long n = 0L;
+        try {
+            n = Long.parseLong(val);
+            System.err.println("parseLong(" + val + ") incorrectly returned " + n);
+            throw new RuntimeException();
+        } catch (NumberFormatException nfe) {
+            ; // Expected
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Math/AbsPositiveZero.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,73 @@
+/*
+ * Copyright 1998 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @bug 4096278
+   @summary Math.abs(+0.0) wrong
+   @author Anand Palaniswamy
+ */
+public class AbsPositiveZero {
+    private static boolean isPositiveZero(float f) {
+        return Float.floatToIntBits(f) == Float.floatToIntBits(0.0f);
+    }
+
+    private static boolean isPositiveZero(double d) {
+        return Double.doubleToLongBits(d) == Double.doubleToLongBits(0.0d);
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (!isPositiveZero(Math.abs(-0.0d))) {
+            throw new Exception("abs(-0.0d) failed");
+        }
+        if (!isPositiveZero(Math.abs(+0.0d))) {
+            throw new Exception("abs(+0.0d) failed");
+        }
+        if (Math.abs(Double.POSITIVE_INFINITY) != Double.POSITIVE_INFINITY) {
+            throw new Exception("abs(+Inf) failed");
+        }
+        if (Math.abs(Double.NEGATIVE_INFINITY) != Double.POSITIVE_INFINITY) {
+            throw new Exception("abs(-Inf) failed");
+        }
+        double dnanval = Math.abs(Double.NaN);
+        if (dnanval == dnanval) {
+            throw new Exception("abs(NaN) failed");
+        }
+
+        if (!isPositiveZero(Math.abs(-0.0f))) {
+            throw new Exception("abs(-0.0f) failed");
+        }
+        if (!isPositiveZero(Math.abs(+0.0f))) {
+            throw new Exception("abs(+0.0f) failed");
+        }
+        if (Math.abs(Float.POSITIVE_INFINITY) != Float.POSITIVE_INFINITY) {
+            throw new Exception("abs(+Inf) failed");
+        }
+        if (Math.abs(Float.NEGATIVE_INFINITY) != Float.POSITIVE_INFINITY) {
+            throw new Exception("abs(-Inf) failed");
+        }
+        float fnanval = Math.abs(Float.NaN);
+        if (fnanval == fnanval) {
+            throw new Exception("abs(NaN) failed");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Math/Atan2Tests.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4984407
+ * @summary Tests for {Math, StrictMath}.atan2
+ * @compile -source 1.5 Atan2Tests.java
+ * @run main Atan2Tests
+ * @author Joseph D. Darcy
+ */
+
+public class Atan2Tests {
+    private Atan2Tests(){}
+
+    static int testAtan2Case(double input1, double input2, double expected) {
+        int failures = 0;
+        failures += Tests.test("StrictMath.atan2(double, double)", input1, input2,
+                               StrictMath.atan2(input1, input2), expected);
+        failures += Tests.test("Math.atan2(double, double)", input1, input2,
+                               Math.atan2(input1, input2), expected);
+
+        return failures;
+    }
+
+    static int testAtan2() {
+        int failures = 0;
+
+        double [][] testCases = {
+            {-3.0,      Double.POSITIVE_INFINITY,       -0.0},
+        };
+
+        for (double[] testCase : testCases) {
+            failures+=testAtan2Case(testCase[0], testCase[1], testCase[2]);
+        }
+
+        return failures;
+    }
+
+    public static void main(String [] argv) {
+        int failures = 0;
+
+        failures += testAtan2();
+
+        if (failures > 0) {
+            System.err.println("Testing atan2 incurred "
+                               + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Math/CubeRootTests.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,336 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4347132 4939441
+ * @summary Tests for {Math, StrictMath}.cbrt
+ * @author Joseph D. Darcy
+ */
+
+import sun.misc.FpUtils;
+import sun.misc.DoubleConsts;
+
+public class CubeRootTests {
+    private CubeRootTests(){}
+
+    static final double infinityD = Double.POSITIVE_INFINITY;
+    static final double NaNd = Double.NaN;
+
+    // Initialize shared random number generator
+    static java.util.Random rand = new java.util.Random();
+
+    static int testCubeRootCase(double input, double expected) {
+        int failures=0;
+
+        double minus_input = -input;
+        double minus_expected = -expected;
+
+        failures+=Tests.test("Math.cbrt(double)", input,
+                             Math.cbrt(input), expected);
+        failures+=Tests.test("Math.cbrt(double)", minus_input,
+                             Math.cbrt(minus_input), minus_expected);
+        failures+=Tests.test("StrictMath.cbrt(double)", input,
+                             StrictMath.cbrt(input), expected);
+        failures+=Tests.test("StrictMath.cbrt(double)", minus_input,
+                             StrictMath.cbrt(minus_input), minus_expected);
+
+        return failures;
+    }
+
+    static int testCubeRoot() {
+        int failures = 0;
+        double [][] testCases = {
+            {NaNd,                      NaNd},
+            {Double.longBitsToDouble(0x7FF0000000000001L),      NaNd},
+            {Double.longBitsToDouble(0xFFF0000000000001L),      NaNd},
+            {Double.longBitsToDouble(0x7FF8555555555555L),      NaNd},
+            {Double.longBitsToDouble(0xFFF8555555555555L),      NaNd},
+            {Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL),      NaNd},
+            {Double.longBitsToDouble(0xFFFFFFFFFFFFFFFFL),      NaNd},
+            {Double.longBitsToDouble(0x7FFDeadBeef00000L),      NaNd},
+            {Double.longBitsToDouble(0xFFFDeadBeef00000L),      NaNd},
+            {Double.longBitsToDouble(0x7FFCafeBabe00000L),      NaNd},
+            {Double.longBitsToDouble(0xFFFCafeBabe00000L),      NaNd},
+            {Double.POSITIVE_INFINITY,  Double.POSITIVE_INFINITY},
+            {Double.NEGATIVE_INFINITY,  Double.NEGATIVE_INFINITY},
+            {+0.0,                      +0.0},
+            {-0.0,                      -0.0},
+            {+1.0,                      +1.0},
+            {-1.0,                      -1.0},
+            {+8.0,                      +2.0},
+            {-8.0,                      -2.0}
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            failures += testCubeRootCase(testCases[i][0],
+                                         testCases[i][1]);
+        }
+
+        // Test integer perfect cubes less than 2^53.
+        for(int i = 0; i <= 208063; i++) {
+            double d = i;
+            failures += testCubeRootCase(d*d*d, (double)i);
+        }
+
+        // Test cbrt(2^(3n)) = 2^n.
+        for(int i = 18; i <= DoubleConsts.MAX_EXPONENT/3; i++) {
+            failures += testCubeRootCase(FpUtils.scalb(1.0, 3*i),
+                                         FpUtils.scalb(1.0, i) );
+        }
+
+        // Test cbrt(2^(-3n)) = 2^-n.
+        for(int i = -1; i >= FpUtils.ilogb(Double.MIN_VALUE)/3; i--) {
+            failures += testCubeRootCase(FpUtils.scalb(1.0, 3*i),
+                                         FpUtils.scalb(1.0, i) );
+        }
+
+        // Test random perfect cubes.  Create double values with
+        // modest exponents but only have at most the 17 most
+        // significant bits in the significand set; 17*3 = 51, which
+        // is less than the number of bits in a double's significand.
+        long exponentBits1 =
+            Double.doubleToLongBits(FpUtils.scalb(1.0, 55)) &
+            DoubleConsts.EXP_BIT_MASK;
+        long exponentBits2=
+            Double.doubleToLongBits(FpUtils.scalb(1.0, -55)) &
+            DoubleConsts.EXP_BIT_MASK;
+        for(int i = 0; i < 100; i++) {
+            // Take 16 bits since the 17th bit is implicit in the
+            // exponent
+           double input1 =
+               Double.longBitsToDouble(exponentBits1 |
+                                       // Significand bits
+                                       ((long) (rand.nextInt() & 0xFFFF))<<
+                                       (DoubleConsts.SIGNIFICAND_WIDTH-1-16));
+           failures += testCubeRootCase(input1*input1*input1, input1);
+
+           double input2 =
+               Double.longBitsToDouble(exponentBits2 |
+                                       // Significand bits
+                                       ((long) (rand.nextInt() & 0xFFFF))<<
+                                       (DoubleConsts.SIGNIFICAND_WIDTH-1-16));
+           failures += testCubeRootCase(input2*input2*input2, input2);
+        }
+
+        // Directly test quality of implementation properties of cbrt
+        // for values that aren't perfect cubes.  Verify returned
+        // result meets the 1 ulp test.  That is, we want to verify
+        // that for positive x > 1,
+        // y = cbrt(x),
+        //
+        // if (err1=x - y^3 ) < 0, abs((y_pp^3 -x )) < err1
+        // if (err1=x - y^3 ) > 0, abs((y_mm^3 -x )) < err1
+        //
+        // where y_mm and y_pp are the next smaller and next larger
+        // floating-point value to y.  In other words, if y^3 is too
+        // big, making y larger does not improve the result; likewise,
+        // if y^3 is too small, making y smaller does not improve the
+        // result.
+        //
+        // ...-----|--?--|--?--|-----... Where is the true result?
+        //         y_mm  y     y_pp
+        //
+        // The returned value y should be one of the floating-point
+        // values braketing the true result.  However, given y, a
+        // priori we don't know if the true result falls in [y_mm, y]
+        // or [y, y_pp].  The above test looks at the error in x-y^3
+        // to determine which region the true result is in; e.g. if
+        // y^3 is smaller than x, the true result should be in [y,
+        // y_pp].  Therefore, it would be an error for y_mm to be a
+        // closer approximation to x^(1/3).  In this case, it is
+        // permissible, although not ideal, for y_pp^3 to be a closer
+        // approximation to x^(1/3) than y^3.
+        //
+        // We will use pow(y,3) to compute y^3.  Although pow is not
+        // correctly rounded, StrictMath.pow should have at most 1 ulp
+        // error.  For y > 1, pow(y_mm,3) and pow(y_pp,3) will differ
+        // from pow(y,3) by more than one ulp so the comparision of
+        // errors should still be valid.
+
+        for(int i = 0; i < 1000; i++) {
+            double d = 1.0 + rand.nextDouble();
+            double err, err_adjacent;
+
+            double y1 = Math.cbrt(d);
+            double y2 = StrictMath.cbrt(d);
+
+            err = d - StrictMath.pow(y1, 3);
+            if (err != 0.0) {
+                if(FpUtils.isNaN(err)) {
+                    failures++;
+                    System.err.println("Encountered unexpected NaN value: d = " + d +
+                                       "\tcbrt(d) = " + y1);
+                } else {
+                    if (err < 0.0) {
+                        err_adjacent = StrictMath.pow(FpUtils.nextUp(y1), 3) - d;
+                    }
+                    else  { // (err > 0.0)
+                        err_adjacent = StrictMath.pow(FpUtils.nextAfter(y1,0.0), 3) - d;
+                    }
+
+                    if (Math.abs(err) > Math.abs(err_adjacent)) {
+                        failures++;
+                        System.err.println("For Math.cbrt(" + d + "), returned result " +
+                                           y1 + "is not as good as adjacent value.");
+                    }
+                }
+            }
+
+
+            err = d - StrictMath.pow(y2, 3);
+            if (err != 0.0) {
+                if(FpUtils.isNaN(err)) {
+                    failures++;
+                    System.err.println("Encountered unexpected NaN value: d = " + d +
+                                       "\tcbrt(d) = " + y2);
+                } else {
+                    if (err < 0.0) {
+                        err_adjacent = StrictMath.pow(FpUtils.nextUp(y2), 3) - d;
+                    }
+                    else  { // (err > 0.0)
+                        err_adjacent = StrictMath.pow(FpUtils.nextAfter(y2,0.0), 3) - d;
+                    }
+
+                    if (Math.abs(err) > Math.abs(err_adjacent)) {
+                        failures++;
+                        System.err.println("For StrictMath.cbrt(" + d + "), returned result " +
+                                           y2 + "is not as good as adjacent value.");
+                    }
+                }
+            }
+
+
+        }
+
+        // Test monotonicity properites near perfect cubes; test two
+        // numbers before and two numbers after; i.e. for
+        //
+        // pcNeighbors[] =
+        // {nextDown(nextDown(pc)),
+        // nextDown(pc),
+        // pc,
+        // nextUp(pc),
+        // nextUp(nextUp(pc))}
+        //
+        // test that cbrt(pcNeighbors[i]) <= cbrt(pcNeighbors[i+1])
+        {
+
+            double pcNeighbors[] = new double[5];
+            double pcNeighborsCbrt[] = new double[5];
+            double pcNeighborsStrictCbrt[] = new double[5];
+
+            // Test near cbrt(2^(3n)) = 2^n.
+            for(int i = 18; i <= DoubleConsts.MAX_EXPONENT/3; i++) {
+                double pc = FpUtils.scalb(1.0, 3*i);
+
+                pcNeighbors[2] = pc;
+                pcNeighbors[1] = FpUtils.nextDown(pc);
+                pcNeighbors[0] = FpUtils.nextDown(pcNeighbors[1]);
+                pcNeighbors[3] = FpUtils.nextUp(pc);
+                pcNeighbors[4] = FpUtils.nextUp(pcNeighbors[3]);
+
+                for(int j = 0; j < pcNeighbors.length; j++) {
+                    pcNeighborsCbrt[j] =           Math.cbrt(pcNeighbors[j]);
+                    pcNeighborsStrictCbrt[j] = StrictMath.cbrt(pcNeighbors[j]);
+                }
+
+                for(int j = 0; j < pcNeighborsCbrt.length-1; j++) {
+                    if(pcNeighborsCbrt[j] >  pcNeighborsCbrt[j+1] ) {
+                        failures++;
+                        System.err.println("Monotonicity failure for Math.cbrt on " +
+                                          pcNeighbors[j] + " and "  +
+                                          pcNeighbors[j+1] + "\n\treturned " +
+                                          pcNeighborsCbrt[j] + " and " +
+                                          pcNeighborsCbrt[j+1] );
+                    }
+
+                    if(pcNeighborsStrictCbrt[j] >  pcNeighborsStrictCbrt[j+1] ) {
+                        failures++;
+                        System.err.println("Monotonicity failure for StrictMath.cbrt on " +
+                                          pcNeighbors[j] + " and "  +
+                                          pcNeighbors[j+1] + "\n\treturned " +
+                                          pcNeighborsStrictCbrt[j] + " and " +
+                                          pcNeighborsStrictCbrt[j+1] );
+                    }
+
+
+                }
+
+            }
+
+            // Test near cbrt(2^(-3n)) = 2^-n.
+            for(int i = -1; i >= FpUtils.ilogb(Double.MIN_VALUE)/3; i--) {
+                double pc = FpUtils.scalb(1.0, 3*i);
+
+                pcNeighbors[2] = pc;
+                pcNeighbors[1] = FpUtils.nextDown(pc);
+                pcNeighbors[0] = FpUtils.nextDown(pcNeighbors[1]);
+                pcNeighbors[3] = FpUtils.nextUp(pc);
+                pcNeighbors[4] = FpUtils.nextUp(pcNeighbors[3]);
+
+                for(int j = 0; j < pcNeighbors.length; j++) {
+                    pcNeighborsCbrt[j] =           Math.cbrt(pcNeighbors[j]);
+                    pcNeighborsStrictCbrt[j] = StrictMath.cbrt(pcNeighbors[j]);
+                }
+
+                for(int j = 0; j < pcNeighborsCbrt.length-1; j++) {
+                    if(pcNeighborsCbrt[j] >  pcNeighborsCbrt[j+1] ) {
+                        failures++;
+                        System.err.println("Monotonicity failure for Math.cbrt on " +
+                                          pcNeighbors[j] + " and "  +
+                                          pcNeighbors[j+1] + "\n\treturned " +
+                                          pcNeighborsCbrt[j] + " and " +
+                                          pcNeighborsCbrt[j+1] );
+                    }
+
+                    if(pcNeighborsStrictCbrt[j] >  pcNeighborsStrictCbrt[j+1] ) {
+                        failures++;
+                        System.err.println("Monotonicity failure for StrictMath.cbrt on " +
+                                          pcNeighbors[j] + " and "  +
+                                          pcNeighbors[j+1] + "\n\treturned " +
+                                          pcNeighborsStrictCbrt[j] + " and " +
+                                          pcNeighborsStrictCbrt[j+1] );
+                    }
+
+
+                }
+            }
+        }
+
+        return failures;
+    }
+
+    public static void main(String argv[]) {
+        int failures = 0;
+
+        failures += testCubeRoot();
+
+        if (failures > 0) {
+            System.err.println("Testing cbrt incurred "
+                               + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Math/Expm1Tests.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,231 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4851638 4900189 4939441
+ * @summary Tests for {Math, StrictMath}.expm1
+ * @author Joseph D. Darcy
+ */
+
+import sun.misc.DoubleConsts;
+import sun.misc.FpUtils;
+
+/*
+ * The Taylor expansion of expxm1(x) = exp(x) -1 is
+ *
+ * 1 + x/1! + x^2/2! + x^3/3| + ... -1 =
+ *
+ * x + x^2/2! + x^3/3 + ...
+ *
+ * Therefore, for small values of x, expxm1 ~= x.
+ *
+ * For large values of x, expxm1(x) ~= exp(x)
+ *
+ * For large negative x, expxm1(x) ~= -1.
+ */
+
+public class Expm1Tests {
+
+    private Expm1Tests(){}
+
+    static final double infinityD = Double.POSITIVE_INFINITY;
+    static final double NaNd = Double.NaN;
+
+    static int testExpm1() {
+        int failures = 0;
+
+        double [][] testCases = {
+            {Double.NaN,                NaNd},
+            {Double.longBitsToDouble(0x7FF0000000000001L),      NaNd},
+            {Double.longBitsToDouble(0xFFF0000000000001L),      NaNd},
+            {Double.longBitsToDouble(0x7FF8555555555555L),      NaNd},
+            {Double.longBitsToDouble(0xFFF8555555555555L),      NaNd},
+            {Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL),      NaNd},
+            {Double.longBitsToDouble(0xFFFFFFFFFFFFFFFFL),      NaNd},
+            {Double.longBitsToDouble(0x7FFDeadBeef00000L),      NaNd},
+            {Double.longBitsToDouble(0xFFFDeadBeef00000L),      NaNd},
+            {Double.longBitsToDouble(0x7FFCafeBabe00000L),      NaNd},
+            {Double.longBitsToDouble(0xFFFCafeBabe00000L),      NaNd},
+            {infinityD,                 infinityD},
+            {-infinityD,                -1.0},
+            {-0.0,                      -0.0},
+            {+0.0,                      +0.0},
+        };
+
+        // Test special cases
+        for(int i = 0; i < testCases.length; i++) {
+            failures += testExpm1CaseWithUlpDiff(testCases[i][0],
+                                                 testCases[i][1], 0, null);
+        }
+
+
+        // For |x| < 2^-54 expm1(x) ~= x
+        for(int i = DoubleConsts.MIN_SUB_EXPONENT; i <= -54; i++) {
+            double d = FpUtils.scalb(2, i);
+            failures += testExpm1Case(d, d);
+            failures += testExpm1Case(-d, -d);
+        }
+
+
+        // For values of y where exp(y) > 2^54, expm1(x) ~= exp(x).
+        // The least such y is ln(2^54) ~= 37.42994775023705; exp(x)
+        // overflows for x > ~= 709.8
+
+        // Use a 2-ulp error threshold to account for errors in the
+        // exp implementation; the increments of d in the loop will be
+        // exact.
+        for(double d = 37.5; d <= 709.5; d += 1.0) {
+            failures += testExpm1CaseWithUlpDiff(d, StrictMath.exp(d), 2, null);
+        }
+
+        // For x > 710, expm1(x) should be infinity
+        for(int i = 10; i <= DoubleConsts.MAX_EXPONENT; i++) {
+            double d = FpUtils.scalb(2, i);
+            failures += testExpm1Case(d, infinityD);
+        }
+
+        // By monotonicity, once the limit is reached, the
+        // implemenation should return the limit for all smaller
+        // values.
+        boolean reachedLimit [] = {false, false};
+
+        // Once exp(y) < 0.5 * ulp(1), expm1(y) ~= -1.0;
+        // The greatest such y is ln(2^-53) ~= -36.7368005696771.
+        for(double d = -36.75; d >= -127.75; d -= 1.0) {
+            failures += testExpm1CaseWithUlpDiff(d, -1.0, 1,
+                                                 reachedLimit);
+        }
+
+        for(int i = 7; i <= DoubleConsts.MAX_EXPONENT; i++) {
+            double d = -FpUtils.scalb(2, i);
+            failures += testExpm1CaseWithUlpDiff(d, -1.0, 1, reachedLimit);
+        }
+
+        // Test for monotonicity failures near multiples of log(2).
+        // Test two numbers before and two numbers after each chosen
+        // value; i.e.
+        //
+        // pcNeighbors[] =
+        // {nextDown(nextDown(pc)),
+        // nextDown(pc),
+        // pc,
+        // nextUp(pc),
+        // nextUp(nextUp(pc))}
+        //
+        // and we test that expm1(pcNeighbors[i]) <= expm1(pcNeighbors[i+1])
+        {
+            double pcNeighbors[] = new double[5];
+            double pcNeighborsExpm1[] = new double[5];
+            double pcNeighborsStrictExpm1[] = new double[5];
+
+            for(int i = -50; i <= 50; i++) {
+                double pc = StrictMath.log(2)*i;
+
+                pcNeighbors[2] = pc;
+                pcNeighbors[1] = FpUtils.nextDown(pc);
+                pcNeighbors[0] = FpUtils.nextDown(pcNeighbors[1]);
+                pcNeighbors[3] = FpUtils.nextUp(pc);
+                pcNeighbors[4] = FpUtils.nextUp(pcNeighbors[3]);
+
+                for(int j = 0; j < pcNeighbors.length; j++) {
+                    pcNeighborsExpm1[j]       =       Math.expm1(pcNeighbors[j]);
+                    pcNeighborsStrictExpm1[j] = StrictMath.expm1(pcNeighbors[j]);
+                }
+
+                for(int j = 0; j < pcNeighborsExpm1.length-1; j++) {
+                    if(pcNeighborsExpm1[j] >  pcNeighborsExpm1[j+1] ) {
+                        failures++;
+                        System.err.println("Monotonicity failure for Math.expm1 on " +
+                                          pcNeighbors[j] + " and "  +
+                                          pcNeighbors[j+1] + "\n\treturned " +
+                                          pcNeighborsExpm1[j] + " and " +
+                                          pcNeighborsExpm1[j+1] );
+                    }
+
+                    if(pcNeighborsStrictExpm1[j] >  pcNeighborsStrictExpm1[j+1] ) {
+                        failures++;
+                        System.err.println("Monotonicity failure for StrictMath.expm1 on " +
+                                          pcNeighbors[j] + " and "  +
+                                          pcNeighbors[j+1] + "\n\treturned " +
+                                          pcNeighborsStrictExpm1[j] + " and " +
+                                          pcNeighborsStrictExpm1[j+1] );
+                    }
+
+
+                }
+
+            }
+        }
+
+        return failures;
+    }
+
+    public static int testExpm1Case(double input,
+                                    double expected) {
+        return testExpm1CaseWithUlpDiff(input, expected, 1, null);
+    }
+
+    public static int testExpm1CaseWithUlpDiff(double input,
+                                               double expected,
+                                               double ulps,
+                                               boolean [] reachedLimit) {
+        int failures = 0;
+        double mathUlps = ulps, strictUlps = ulps;
+        double mathOutput;
+        double strictOutput;
+
+        if (reachedLimit != null) {
+            if (reachedLimit[0])
+                mathUlps = 0;
+
+            if (reachedLimit[1])
+                strictUlps = 0;
+        }
+
+        failures += Tests.testUlpDiffWithLowerBound("Math.expm1(double)",
+                                                    input, mathOutput=Math.expm1(input),
+                                                    expected, mathUlps, -1.0);
+        failures += Tests.testUlpDiffWithLowerBound("StrictMath.expm1(double)",
+                                                    input, strictOutput=StrictMath.expm1(input),
+                                                    expected, strictUlps, -1.0);
+        if (reachedLimit != null) {
+            reachedLimit[0] |= (mathOutput   == -1.0);
+            reachedLimit[1] |= (strictOutput == -1.0);
+        }
+
+        return failures;
+    }
+
+    public static void main(String argv[]) {
+        int failures = 0;
+
+        failures += testExpm1();
+
+        if (failures > 0) {
+            System.err.println("Testing expm1 incurred "
+                               + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Math/HyperbolicTests.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,1065 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4851625 4900189 4939441
+ * @summary Tests for {Math, StrictMath}.{sinh, cosh, tanh}
+ * @author Joseph D. Darcy
+ */
+
+import sun.misc.DoubleConsts;
+import sun.misc.FpUtils;
+
+public class HyperbolicTests {
+    private HyperbolicTests(){}
+
+    static final double NaNd = Double.NaN;
+
+    /**
+     * Test accuracy of {Math, StrictMath}.sinh.  The specified
+     * accuracy is 2.5 ulps.
+     *
+     * The defintion of sinh(x) is
+     *
+     * (e^x - e^(-x))/2
+     *
+     * The series expansion of sinh(x) =
+     *
+     * x + x^3/3! + x^5/5! + x^7/7! +...
+     *
+     * Therefore,
+     *
+     * 1. For large values of x sinh(x) ~= signum(x)*exp(|x|)/2
+     *
+     * 2. For small values of x, sinh(x) ~= x.
+     *
+     * Additionally, sinh is an odd function; sinh(-x) = -sinh(x).
+     *
+     */
+    static int testSinh() {
+        int failures = 0;
+        /*
+         * Array elements below generated using a quad sinh
+         * implementation.  Rounded to a double, the quad result
+         * *should* be correctly rounded, unless we are quite unlucky.
+         * Assuming the quad value is a correctly rounded double, the
+         * allowed error is 3.0 ulps instead of 2.5 since the quad
+         * value rounded to double can have its own 1/2 ulp error.
+         */
+        double [][] testCases = {
+            // x                sinh(x)
+            {0.0625,            0.06254069805219182172183988501029229},
+            {0.1250,            0.12532577524111545698205754229137154},
+            {0.1875,            0.18860056562029018382047025055167585},
+            {0.2500,            0.25261231680816830791412515054205787},
+            {0.3125,            0.31761115611357728583959867611490292},
+            {0.3750,            0.38385106791361456875429567642050245},
+            {0.4375,            0.45159088610312053032509815226723017},
+            {0.5000,            0.52109530549374736162242562641149155},
+            {0.5625,            0.59263591611468777373870867338492247},
+            {0.6250,            0.66649226445661608227260655608302908},
+            {0.6875,            0.74295294580567543571442036910465007},
+            {0.7500,            0.82231673193582998070366163444691386},
+            {0.8125,            0.90489373856606433650504536421491368},
+            {0.8750,            0.99100663714429475605317427568995231},
+            {0.9375,            1.08099191569306394011007867453992548},
+            {1.0000,            1.17520119364380145688238185059560082},
+            {1.0625,            1.27400259579739321279181130344911907},
+            {1.1250,            1.37778219077984075760379987065228373},
+            {1.1875,            1.48694549961380717221109202361777593},
+            {1.2500,            1.60191908030082563790283030151221415},
+            {1.3125,            1.72315219460596010219069206464391528},
+            {1.3750,            1.85111856355791532419998548438506416},
+            {1.4375,            1.98631821852425112898943304217629457},
+            {1.5000,            2.12927945509481749683438749467763195},
+            {1.5625,            2.28056089740825247058075476705718764},
+            {1.6250,            2.44075368098794353221372986997161132},
+            {1.6875,            2.61048376261693140366028569794027603},
+            {1.7500,            2.79041436627764265509289122308816092},
+            {1.8125,            2.98124857471401377943765253243875520},
+            {1.8750,            3.18373207674259205101326780071803724},
+            {1.9375,            3.39865608104779099764440244167531810},
+            {2.0000,            3.62686040784701876766821398280126192},
+            {2.0625,            3.86923677050642806693938384073620450},
+            {2.1250,            4.12673225993027252260441410537905269},
+            {2.1875,            4.40035304533919660406976249684469164},
+            {2.2500,            4.69116830589833069188357567763552003},
+            {2.3125,            5.00031440855811351554075363240262157},
+            {2.3750,            5.32899934843284576394645856548481489},
+            {2.4375,            5.67850746906785056212578751630266858},
+            {2.5000,            6.05020448103978732145032363835040319},
+            {2.5625,            6.44554279850040875063706020260185553},
+            {2.6250,            6.86606721451642172826145238779845813},
+            {2.6875,            7.31342093738196587585692115636603571},
+            {2.7500,            7.78935201149073201875513401029935330},
+            {2.8125,            8.29572014785741787167717932988491961},
+            {2.8750,            8.83450399097893197351853322827892144},
+            {2.9375,            9.40780885043076394429977972921690859},
+            {3.0000,            10.01787492740990189897459361946582867},
+            {3.0625,            10.66708606836969224165124519209968368},
+            {3.1250,            11.35797907995166028304704128775698426},
+            {3.1875,            12.09325364161259019614431093344260209},
+            {3.2500,            12.87578285468067003959660391705481220},
+            {3.3125,            13.70862446906136798063935858393686525},
+            {3.3750,            14.59503283146163690015482636921657975},
+            {3.4375,            15.53847160182039311025096666980558478},
+            {3.5000,            16.54262728763499762495673152901249743},
+            {3.5625,            17.61142364906941482858466494889121694},
+            {3.6250,            18.74903703113232171399165788088277979},
+            {3.6875,            19.95991268283598684128844120984214675},
+            {3.7500,            21.24878212710338697364101071825171163},
+            {3.8125,            22.62068164929685091969259499078125023},
+            {3.8750,            24.08097197661255803883403419733891573},
+            {3.9375,            25.63535922523855307175060244757748997},
+            {4.0000,            27.28991719712775244890827159079382096},
+            {4.0625,            29.05111111351106713777825462100160185},
+            {4.1250,            30.92582287788986031725487699744107092},
+            {4.1875,            32.92137796722343190618721270937061472},
+            {4.2500,            35.04557405638942942322929652461901154},
+            {4.3125,            37.30671148776788628118833357170042385},
+            {4.3750,            39.71362570500944929025069048612806024},
+            {4.4375,            42.27572177772344954814418332587050658},
+            {4.5000,            45.00301115199178562180965680564371424},
+            {4.5625,            47.90615077031205065685078058248081891},
+            {4.6250,            50.99648471383193131253995134526177467},
+            {4.6875,            54.28608852959281437757368957713936555},
+            {4.7500,            57.78781641599226874961859781628591635},
+            {4.8125,            61.51535145084362283008545918273109379},
+            {4.8750,            65.48325905829987165560146562921543361},
+            {4.9375,            69.70704392356508084094318094283346381},
+            {5.0000,            74.20321057778875897700947199606456364},
+            {5.0625,            78.98932788987998983462810080907521151},
+            {5.1250,            84.08409771724448958901392613147384951},
+            {5.1875,            89.50742798369883598816307922895346849},
+            {5.2500,            95.28051047011540739630959111303975956},
+            {5.3125,            101.42590362176666730633859252034238987},
+            {5.3750,            107.96762069594029162704530843962700133},
+            {5.4375,            114.93122359426386042048760580590182604},
+            {5.5000,            122.34392274639096192409774240457730721},
+            {5.5625,            130.23468343534638291488502321709913206},
+            {5.6250,            138.63433897999898233879574111119546728},
+            {5.6875,            147.57571121692522056519568264304815790},
+            {5.7500,            157.09373875244884423880085377625986165},
+            {5.8125,            167.22561348600435888568183143777868662},
+            {5.8750,            178.01092593829229887752609866133883987},
+            {5.9375,            189.49181995209921964640216682906501778},
+            {6.0000,            201.71315737027922812498206768797872263},
+            {6.0625,            214.72269333437984291483666459592578915},
+            {6.1250,            228.57126288889537420461281285729970085},
+            {6.1875,            243.31297962030799867970551767086092471},
+            {6.2500,            259.00544710710289911522315435345489966},
+            {6.3125,            275.70998400700299790136562219920451185},
+            {6.3750,            293.49186366095654566861661249898332253},
+            {6.4375,            312.42056915013535342987623229485223434},
+            {6.5000,            332.57006480258443156075705566965111346},
+            {6.5625,            354.01908521044116928437570109827956007},
+            {6.6250,            376.85144288706511933454985188849781703},
+            {6.6875,            401.15635576625530823119100750634165252},
+            {6.7500,            427.02879582326538080306830640235938517},
+            {6.8125,            454.56986017986077163530945733572724452},
+            {6.8750,            483.88716614351897894746751705315210621},
+            {6.9375,            515.09527172439720070161654727225752288},
+            {7.0000,            548.31612327324652237375611757601851598},
+            {7.0625,            583.67953198942753384680988096024373270},
+            {7.1250,            621.32368116099280160364794462812762880},
+            {7.1875,            661.39566611888784148449430491465857519},
+            {7.2500,            704.05206901515336623551137120663358760},
+            {7.3125,            749.45957067108712382864538206200700256},
+            {7.3750,            797.79560188617531521347351754559776282},
+            {7.4375,            849.24903675279739482863565789325699416},
+            {7.5000,            904.02093068584652953510919038935849651},
+            {7.5625,            962.32530605113249628368993221570636328},
+            {7.6250,            1024.38998846242707559349318193113614698},
+            {7.6875,            1090.45749701500081956792547346904792325},
+            {7.7500,            1160.78599193425808533255719118417856088},
+            {7.8125,            1235.65028334242796895820912936318532502},
+            {7.8750,            1315.34290508508890654067255740428824014},
+            {7.9375,            1400.17525781352742299995139486063802583},
+            {8.0000,            1490.47882578955018611587663903188144796},
+            {8.0625,            1586.60647216744061169450001100145859236},
+            {8.1250,            1688.93381781440241350635231605477507900},
+            {8.1875,            1797.86070905726094477721128358866360644},
+            {8.2500,            1913.81278009067446281883262689250118009},
+            {8.3125,            2037.24311615199935553277163192983440062},
+            {8.3750,            2168.63402396170125867037749369723761636},
+            {8.4375,            2308.49891634734644432370720900969004306},
+            {8.5000,            2457.38431841538268239359965370719928775},
+            {8.5625,            2615.87200310986940554256648824234335262},
+            {8.6250,            2784.58126450289932429469130598902487336},
+            {8.6875,            2964.17133769964321637973459949999057146},
+            {8.7500,            3155.34397481384944060352507473513108710},
+            {8.8125,            3358.84618707947841898217318996045550438},
+            {8.8750,            3575.47316381333288862617411467285480067},
+            {8.9375,            3806.07137963459383403903729660349293583},
+            {9.0000,            4051.54190208278996051522359589803425598},
+            {9.0625,            4312.84391255878980330955246931164633615},
+            {9.1250,            4590.99845434696991399363282718106006883},
+            {9.1875,            4887.09242236403719571363798584676797558},
+            {9.2500,            5202.28281022453561319352901552085348309},
+            {9.3125,            5537.80123121853803935727335892054791265},
+            {9.3750,            5894.95873086734181634245918412592155656},
+            {9.4375,            6275.15090986233399457103055108344546942},
+            {9.5000,            6679.86337740502119410058225086262108741},
+            {9.5625,            7110.67755625726876329967852256934334025},
+            {9.6250,            7569.27686218510919585241049433331592115},
+            {9.6875,            8057.45328194243077504648484392156371121},
+            {9.7500,            8577.11437549816065709098061006273039092},
+            {9.8125,            9130.29072986829727910801024120918114778},
+            {9.8750,            9719.14389367880274015504995181862860062},
+            {9.9375,            10345.97482346383208590278839409938269134},
+            {10.0000,           11013.23287470339337723652455484636420303},
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            double [] testCase = testCases[i];
+            failures += testSinhCaseWithUlpDiff(testCase[0],
+                                                testCase[1],
+                                                3.0);
+        }
+
+        double [][] specialTestCases = {
+            {0.0,                       0.0},
+            {NaNd,                      NaNd},
+            {Double.longBitsToDouble(0x7FF0000000000001L),      NaNd},
+            {Double.longBitsToDouble(0xFFF0000000000001L),      NaNd},
+            {Double.longBitsToDouble(0x7FF8555555555555L),      NaNd},
+            {Double.longBitsToDouble(0xFFF8555555555555L),      NaNd},
+            {Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL),      NaNd},
+            {Double.longBitsToDouble(0xFFFFFFFFFFFFFFFFL),      NaNd},
+            {Double.longBitsToDouble(0x7FFDeadBeef00000L),      NaNd},
+            {Double.longBitsToDouble(0xFFFDeadBeef00000L),      NaNd},
+            {Double.longBitsToDouble(0x7FFCafeBabe00000L),      NaNd},
+            {Double.longBitsToDouble(0xFFFCafeBabe00000L),      NaNd},
+            {Double.POSITIVE_INFINITY,  Double.POSITIVE_INFINITY}
+        };
+
+        for(int i = 0; i < specialTestCases.length; i++) {
+            failures += testSinhCaseWithUlpDiff(specialTestCases[i][0],
+                                                specialTestCases[i][1],
+                                                0.0);
+        }
+
+        // For powers of 2 less than 2^(-27), the second and
+        // subsequent terms of the Taylor series expansion will get
+        // rounded away since |n-n^3| > 53, the binary precision of a
+        // double significand.
+
+        for(int i = DoubleConsts.MIN_SUB_EXPONENT; i < -27; i++) {
+            double d = FpUtils.scalb(2.0, i);
+
+            // Result and expected are the same.
+            failures += testSinhCaseWithUlpDiff(d, d, 2.5);
+        }
+
+        // For values of x larger than 22, the e^(-x) term is
+        // insignificant to the floating-point result.  Util exp(x)
+        // overflows around 709.8, sinh(x) ~= exp(x)/2; will will test
+        // 10000 values in this range.
+
+        long trans22 = Double.doubleToLongBits(22.0);
+        // (approximately) largest value such that exp shouldn't
+        // overflow
+        long transExpOvfl = Double.doubleToLongBits(FpUtils.nextDown(709.7827128933841));
+
+        for(long i = trans22;
+            i < transExpOvfl;
+            i +=(transExpOvfl-trans22)/10000) {
+
+            double d = Double.longBitsToDouble(i);
+
+            // Allow 3.5 ulps of error to deal with error in exp.
+            failures += testSinhCaseWithUlpDiff(d, StrictMath.exp(d)*0.5, 3.5);
+        }
+
+        // (approximately) largest value such that sinh shouldn't
+        // overflow.
+        long transSinhOvfl = Double.doubleToLongBits(710.4758600739439);
+
+        // Make sure sinh(x) doesn't overflow as soon as exp(x)
+        // overflows.
+
+        /*
+         * For large values of x, sinh(x) ~= 0.5*(e^x).  Therefore,
+         *
+         * sinh(x) ~= e^(ln 0.5) * e^x = e^(x + ln 0.5)
+         *
+         * So, we can calculate the approximate expected result as
+         * exp(x + -0.693147186).  However, this sum suffers from
+         * roundoff, limiting the accuracy of the approximation.  The
+         * accuracy can be improved by recovering the rounded-off
+         * information.  Since x is larger than ln(0.5), the trailing
+         * bits of ln(0.5) get rounded away when the two values are
+         * added.  However, high-order bits of ln(0.5) that
+         * contribute to the sum can be found:
+         *
+         * offset = log(0.5);
+         * effective_offset = (x + offset) - x; // exact subtraction
+         * rounded_away_offset = offset - effective_offset; // exact subtraction
+         *
+         * Therefore, the product
+         *
+         * exp(x + offset)*exp(rounded_away_offset)
+         *
+         * will be a better approximation to the exact value of
+         *
+         * e^(x + offset)
+         *
+         * than exp(x+offset) alone.  (The expected result cannot be
+         * computed as exp(x)*exp(offset) since exp(x) by itself would
+         * overflow to infinity.)
+         */
+        double offset = StrictMath.log(0.5);
+        for(long i = transExpOvfl+1; i < transSinhOvfl;
+            i += (transSinhOvfl-transExpOvfl)/1000 ) {
+            double input = Double.longBitsToDouble(i);
+
+            double expected =
+                StrictMath.exp(input + offset) *
+                StrictMath.exp( offset - ((input + offset) - input) );
+
+            failures += testSinhCaseWithUlpDiff(input, expected, 4.0);
+        }
+
+        // sinh(x) overflows for values greater than 710; in
+        // particular, it overflows for all 2^i, i > 10.
+        for(int i = 10; i <= DoubleConsts.MAX_EXPONENT; i++) {
+            double d = FpUtils.scalb(2.0, i);
+
+            // Result and expected are the same.
+            failures += testSinhCaseWithUlpDiff(d,
+                                                Double.POSITIVE_INFINITY, 0.0);
+        }
+
+        return failures;
+    }
+
+    public static int testSinhCaseWithTolerance(double input,
+                                                double expected,
+                                                double tolerance) {
+        int failures = 0;
+        failures += Tests.testTolerance("Math.sinh(double)",
+                                        input, Math.sinh(input),
+                                        expected, tolerance);
+        failures += Tests.testTolerance("Math.sinh(double)",
+                                        -input, Math.sinh(-input),
+                                        -expected, tolerance);
+
+        failures += Tests.testTolerance("StrictMath.sinh(double)",
+                                        input, StrictMath.sinh(input),
+                                        expected, tolerance);
+        failures += Tests.testTolerance("StrictMath.sinh(double)",
+                                        -input, StrictMath.sinh(-input),
+                                        -expected, tolerance);
+        return failures;
+    }
+
+    public static int testSinhCaseWithUlpDiff(double input,
+                                              double expected,
+                                              double ulps) {
+        int failures = 0;
+        failures += Tests.testUlpDiff("Math.sinh(double)",
+                                      input, Math.sinh(input),
+                                      expected, ulps);
+        failures += Tests.testUlpDiff("Math.sinh(double)",
+                                      -input, Math.sinh(-input),
+                                      -expected, ulps);
+
+        failures += Tests.testUlpDiff("StrictMath.sinh(double)",
+                                      input, StrictMath.sinh(input),
+                                      expected, ulps);
+        failures += Tests.testUlpDiff("StrictMath.sinh(double)",
+                                      -input, StrictMath.sinh(-input),
+                                      -expected, ulps);
+        return failures;
+    }
+
+
+    /**
+     * Test accuracy of {Math, StrictMath}.cosh.  The specified
+     * accuracy is 2.5 ulps.
+     *
+     * The defintion of cosh(x) is
+     *
+     * (e^x + e^(-x))/2
+     *
+     * The series expansion of cosh(x) =
+     *
+     * 1 + x^2/2! + x^4/4! + x^6/6! +...
+     *
+     * Therefore,
+     *
+     * 1. For large values of x cosh(x) ~= exp(|x|)/2
+     *
+     * 2. For small values of x, cosh(x) ~= 1.
+     *
+     * Additionally, cosh is an even function; cosh(-x) = cosh(x).
+     *
+     */
+    static int testCosh() {
+        int failures = 0;
+        /*
+         * Array elements below generated using a quad cosh
+         * implementation.  Rounded to a double, the quad result
+         * *should* be correctly rounded, unless we are quite unlucky.
+         * Assuming the quad value is a correctly rounded double, the
+         * allowed error is 3.0 ulps instead of 2.5 since the quad
+         * value rounded to double can have its own 1/2 ulp error.
+         */
+        double [][] testCases = {
+            // x                cosh(x)
+            {0.0625,            1.001953760865667607841550709632597376},
+            {0.1250,            1.007822677825710859846949685520422223},
+            {0.1875,            1.017629683800690526835115759894757615},
+            {0.2500,            1.031413099879573176159295417520378622},
+            {0.3125,            1.049226785060219076999158096606305793},
+            {0.3750,            1.071140346704586767299498015567016002},
+            {0.4375,            1.097239412531012567673453832328262160},
+            {0.5000,            1.127625965206380785226225161402672030},
+            {0.5625,            1.162418740845610783505338363214045218},
+            {0.6250,            1.201753692975606324229229064105075301},
+            {0.6875,            1.245784523776616395403056980542275175},
+            {0.7500,            1.294683284676844687841708185390181730},
+            {0.8125,            1.348641048647144208352285714214372703},
+            {0.8750,            1.407868656822803158638471458026344506},
+            {0.9375,            1.472597542369862933336886403008640891},
+            {1.0000,            1.543080634815243778477905620757061497},
+            {1.0625,            1.619593348374367728682469968448090763},
+            {1.1250,            1.702434658138190487400868008124755757},
+            {1.1875,            1.791928268324866464246665745956119612},
+            {1.2500,            1.888423877161015738227715728160051696},
+            {1.3125,            1.992298543335143985091891077551921106},
+            {1.3750,            2.103958159362661802010972984204389619},
+            {1.4375,            2.223839037619709260803023946704272699},
+            {1.5000,            2.352409615243247325767667965441644201},
+            {1.5625,            2.490172284559350293104864895029231913},
+            {1.6250,            2.637665356192137582275019088061812951},
+            {1.6875,            2.795465162524235691253423614360562624},
+            {1.7500,            2.964188309728087781773608481754531801},
+            {1.8125,            3.144494087167972176411236052303565201},
+            {1.8750,            3.337087043587520514308832278928116525},
+            {1.9375,            3.542719740149244276729383650503145346},
+            {2.0000,            3.762195691083631459562213477773746099},
+            {2.0625,            3.996372503438463642260225717607554880},
+            {2.1250,            4.246165228196992140600291052990934410},
+            {2.1875,            4.512549935859540340856119781585096760},
+            {2.2500,            4.796567530460195028666793366876218854},
+            {2.3125,            5.099327816921939817643745917141739051},
+            {2.3750,            5.422013837643509250646323138888569746},
+            {2.4375,            5.765886495263270945949271410819116399},
+            {2.5000,            6.132289479663686116619852312817562517},
+            {2.5625,            6.522654518468725462969589397439224177},
+            {2.6250,            6.938506971550673190999796241172117288},
+            {2.6875,            7.381471791406976069645686221095397137},
+            {2.7500,            7.853279872697439591457564035857305647},
+            {2.8125,            8.355774815752725814638234943192709129},
+            {2.8750,            8.890920130482709321824793617157134961},
+            {2.9375,            9.460806908834119747071078865866737196},
+            {3.0000,            10.067661995777765841953936035115890343},
+            {3.0625,            10.713856690753651225304006562698007312},
+            {3.1250,            11.401916013575067700373788969458446177},
+            {3.1875,            12.134528570998387744547733730974713055},
+            {3.2500,            12.914557062512392049483503752322408761},
+            {3.3125,            13.745049466398732213877084541992751273},
+            {3.3750,            14.629250949773302934853381428660210721},
+            {3.4375,            15.570616549147269180921654324879141947},
+            {3.5000,            16.572824671057316125696517821376119469},
+            {3.5625,            17.639791465519127930722105721028711044},
+            {3.6250,            18.775686128468677200079039891415789429},
+            {3.6875,            19.984947192985946987799359614758598457},
+            {3.7500,            21.272299872959396081877161903352144126},
+            {3.8125,            22.642774526961913363958587775566619798},
+            {3.8750,            24.101726314486257781049388094955970560},
+            {3.9375,            25.654856121347151067170940701379544221},
+            {4.0000,            27.308232836016486629201989612067059978},
+            {4.0625,            29.068317063936918520135334110824828950},
+            {4.1250,            30.941986372478026192360480044849306606},
+            {4.1875,            32.936562165180269851350626768308756303},
+            {4.2500,            35.059838290298428678502583470475012235},
+            {4.3125,            37.320111495433027109832850313172338419},
+            {4.3750,            39.726213847251883288518263854094284091},
+            {4.4375,            42.287547242982546165696077854963452084},
+            {4.5000,            45.014120148530027928305799939930642658},
+            {4.5625,            47.916586706774825161786212701923307169},
+            {4.6250,            51.006288368867753140854830589583165950},
+            {4.6875,            54.295298211196782516984520211780624960},
+            {4.7500,            57.796468111195389383795669320243166117},
+            {4.8125,            61.523478966332915041549750463563672435},
+            {4.8750,            65.490894152518731617237739112888213645},
+            {4.9375,            69.714216430810089539924900313140922323},
+            {5.0000,            74.209948524787844444106108044487704798},
+            {5.0625,            78.995657605307475581204965926043112946},
+            {5.1250,            84.090043934600961683400343038519519678},
+            {5.1875,            89.513013937957834087706670952561002466},
+            {5.2500,            95.285757988514588780586084642381131013},
+            {5.3125,            101.430833209098212357990123684449846912},
+            {5.3750,            107.972251614673824873137995865940755392},
+            {5.4375,            114.935573939814969189535554289886848550},
+            {5.5000,            122.348009517829425991091207107262038316},
+            {5.5625,            130.238522601820409078244923165746295574},
+            {5.6250,            138.637945543134998069351279801575968875},
+            {5.6875,            147.579099269447055276899288971207106581},
+            {5.7500,            157.096921533245353905868840194264636395},
+            {5.8125,            167.228603431860671946045256541679445836},
+            {5.8750,            178.013734732486824390148614309727161925},
+            {5.9375,            189.494458570056311567917444025807275896},
+            {6.0000,            201.715636122455894483405112855409538488},
+            {6.0625,            214.725021906554080628430756558271312513},
+            {6.1250,            228.573450380013557089736092321068279231},
+            {6.1875,            243.315034578039208138752165587134488645},
+            {6.2500,            259.007377561239126824465367865430519592},
+            {6.3125,            275.711797500835732516530131577254654076},
+            {6.3750,            293.493567280752348242602902925987643443},
+            {6.4375,            312.422169552825597994104814531010579387},
+            {6.5000,            332.571568241777409133204438572983297292},
+            {6.5625,            354.020497560858198165985214519757890505},
+            {6.6250,            376.852769667496146326030849450983914197},
+            {6.6875,            401.157602161123700280816957271992998156},
+            {6.7500,            427.029966702886171977469256622451185850},
+            {6.8125,            454.570960119471524953536004647195906721},
+            {6.8750,            483.888199441157626584508920036981010995},
+            {6.9375,            515.096242417696720610477570797503766179},
+            {7.0000,            548.317035155212076889964120712102928484},
+            {7.0625,            583.680388623257719787307547662358502345},
+            {7.1250,            621.324485894002926216918634755431456031},
+            {7.1875,            661.396422095589629755266517362992812037},
+            {7.2500,            704.052779189542208784574955807004218856},
+            {7.3125,            749.460237818184878095966335081928645934},
+            {7.3750,            797.796228612873763671070863694973560629},
+            {7.4375,            849.249625508044731271830060572510241864},
+            {7.5000,            904.021483770216677368692292389446994987},
+            {7.5625,            962.325825625814651122171697031114091993},
+            {7.6250,            1024.390476557670599008492465853663578558},
+            {7.6875,            1090.457955538048482588540574008226583335},
+            {7.7500,            1160.786422676798661020094043586456606003},
+            {7.8125,            1235.650687987597295222707689125107720568},
+            {7.8750,            1315.343285214046776004329388551335841550},
+            {7.9375,            1400.175614911635999247504386054087931958},
+            {8.0000,            1490.479161252178088627715460421007179728},
+            {8.0625,            1586.606787305415349050508956232945539108},
+            {8.1250,            1688.934113859132470361718199038326340668},
+            {8.1875,            1797.860987165547537276364148450577336075},
+            {8.2500,            1913.813041349231764486365114317586148767},
+            {8.3125,            2037.243361581700856522236313401822532385},
+            {8.3750,            2168.634254521568851112005905503069409349},
+            {8.4375,            2308.499132938297821208734949028296170563},
+            {8.5000,            2457.384521883751693037774022640629666294},
+            {8.5625,            2615.872194250713123494312356053193077854},
+            {8.6250,            2784.581444063104750127653362960649823247},
+            {8.6875,            2964.171506380845754878370650565756538203},
+            {8.7500,            3155.344133275174556354775488913749659006},
+            {8.8125,            3358.846335940117183452010789979584950102},
+            {8.8750,            3575.473303654961482727206202358956274888},
+            {8.9375,            3806.071511003646460448021740303914939059},
+            {9.0000,            4051.542025492594047194773093534725371440},
+            {9.0625,            4312.844028491571841588188869958240355518},
+            {9.1250,            4590.998563255739769060078863130940205710},
+            {9.1875,            4887.092524674358252509551443117048351290},
+            {9.2500,            5202.282906336187674588222835339193136030},
+            {9.3125,            5537.801321507079474415176386655744387251},
+            {9.3750,            5894.958815685577062811620236195525504885},
+            {9.4375,            6275.150989541692149890530417987358096221},
+            {9.5000,            6679.863452256851081801173722051940058824},
+            {9.5625,            7110.677626574055535297758456126491707647},
+            {9.6250,            7569.276928241617224537226019600213961572},
+            {9.6875,            8057.453343996777301036241026375049070162},
+            {9.7500,            8577.114433792824387959788368429252257664},
+            {9.8125,            9130.290784631065880205118262838330689429},
+            {9.8750,            9719.143945123662919857326995631317996715},
+            {9.9375,            10345.974871791805753327922796701684092861},
+            {10.0000,           11013.232920103323139721376090437880844591},
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            double [] testCase = testCases[i];
+            failures += testCoshCaseWithUlpDiff(testCase[0],
+                                                testCase[1],
+                                                3.0);
+        }
+
+
+        double [][] specialTestCases = {
+            {0.0,                       1.0},
+            {NaNd,                      NaNd},
+            {Double.longBitsToDouble(0x7FF0000000000001L),      NaNd},
+            {Double.longBitsToDouble(0xFFF0000000000001L),      NaNd},
+            {Double.longBitsToDouble(0x7FF8555555555555L),      NaNd},
+            {Double.longBitsToDouble(0xFFF8555555555555L),      NaNd},
+            {Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL),      NaNd},
+            {Double.longBitsToDouble(0xFFFFFFFFFFFFFFFFL),      NaNd},
+            {Double.longBitsToDouble(0x7FFDeadBeef00000L),      NaNd},
+            {Double.longBitsToDouble(0xFFFDeadBeef00000L),      NaNd},
+            {Double.longBitsToDouble(0x7FFCafeBabe00000L),      NaNd},
+            {Double.longBitsToDouble(0xFFFCafeBabe00000L),      NaNd},
+            {Double.POSITIVE_INFINITY,  Double.POSITIVE_INFINITY}
+        };
+
+        for(int i = 0; i < specialTestCases.length; i++ ) {
+            failures += testCoshCaseWithUlpDiff(specialTestCases[i][0],
+                                                specialTestCases[i][1],
+                                                0.0);
+        }
+
+        // For powers of 2 less than 2^(-27), the second and
+        // subsequent terms of the Taylor series expansion will get
+        // rounded.
+
+        for(int i = DoubleConsts.MIN_SUB_EXPONENT; i < -27; i++) {
+            double d = FpUtils.scalb(2.0, i);
+
+            // Result and expected are the same.
+            failures += testCoshCaseWithUlpDiff(d, 1.0, 2.5);
+        }
+
+        // For values of x larger than 22, the e^(-x) term is
+        // insignificant to the floating-point result.  Util exp(x)
+        // overflows around 709.8, cosh(x) ~= exp(x)/2; will will test
+        // 10000 values in this range.
+
+        long trans22 = Double.doubleToLongBits(22.0);
+        // (approximately) largest value such that exp shouldn't
+        // overflow
+        long transExpOvfl = Double.doubleToLongBits(FpUtils.nextDown(709.7827128933841));
+
+        for(long i = trans22;
+            i < transExpOvfl;
+            i +=(transExpOvfl-trans22)/10000) {
+
+            double d = Double.longBitsToDouble(i);
+
+            // Allow 3.5 ulps of error to deal with error in exp.
+            failures += testCoshCaseWithUlpDiff(d, StrictMath.exp(d)*0.5, 3.5);
+        }
+
+        // (approximately) largest value such that cosh shouldn't
+        // overflow.
+        long transCoshOvfl = Double.doubleToLongBits(710.4758600739439);
+
+        // Make sure sinh(x) doesn't overflow as soon as exp(x)
+        // overflows.
+
+        /*
+         * For large values of x, cosh(x) ~= 0.5*(e^x).  Therefore,
+         *
+         * cosh(x) ~= e^(ln 0.5) * e^x = e^(x + ln 0.5)
+         *
+         * So, we can calculate the approximate expected result as
+         * exp(x + -0.693147186).  However, this sum suffers from
+         * roundoff, limiting the accuracy of the approximation.  The
+         * accuracy can be improved by recovering the rounded-off
+         * information.  Since x is larger than ln(0.5), the trailing
+         * bits of ln(0.5) get rounded away when the two values are
+         * added.  However, high-order bits of ln(0.5) that
+         * contribute to the sum can be found:
+         *
+         * offset = log(0.5);
+         * effective_offset = (x + offset) - x; // exact subtraction
+         * rounded_away_offset = offset - effective_offset; // exact subtraction
+         *
+         * Therefore, the product
+         *
+         * exp(x + offset)*exp(rounded_away_offset)
+         *
+         * will be a better approximation to the exact value of
+         *
+         * e^(x + offset)
+         *
+         * than exp(x+offset) alone.  (The expected result cannot be
+         * computed as exp(x)*exp(offset) since exp(x) by itself would
+         * overflow to infinity.)
+         */
+        double offset = StrictMath.log(0.5);
+        for(long i = transExpOvfl+1; i < transCoshOvfl;
+            i += (transCoshOvfl-transExpOvfl)/1000 ) {
+            double input = Double.longBitsToDouble(i);
+
+            double expected =
+                StrictMath.exp(input + offset) *
+                StrictMath.exp( offset - ((input + offset) - input) );
+
+            failures += testCoshCaseWithUlpDiff(input, expected, 4.0);
+        }
+
+        // cosh(x) overflows for values greater than 710; in
+        // particular, it overflows for all 2^i, i > 10.
+        for(int i = 10; i <= DoubleConsts.MAX_EXPONENT; i++) {
+            double d = FpUtils.scalb(2.0, i);
+
+            // Result and expected are the same.
+            failures += testCoshCaseWithUlpDiff(d,
+                                                Double.POSITIVE_INFINITY, 0.0);
+        }
+        return failures;
+    }
+
+    public static int testCoshCaseWithTolerance(double input,
+                                                double expected,
+                                                double tolerance) {
+        int failures = 0;
+        failures += Tests.testTolerance("Math.cosh(double)",
+                                        input, Math.cosh(input),
+                                        expected, tolerance);
+        failures += Tests.testTolerance("Math.cosh(double)",
+                                        -input, Math.cosh(-input),
+                                        expected, tolerance);
+
+        failures += Tests.testTolerance("StrictMath.cosh(double)",
+                                        input, StrictMath.cosh(input),
+                                        expected, tolerance);
+        failures += Tests.testTolerance("StrictMath.cosh(double)",
+                                        -input, StrictMath.cosh(-input),
+                                        expected, tolerance);
+        return failures;
+    }
+
+    public static int testCoshCaseWithUlpDiff(double input,
+                                              double expected,
+                                              double ulps) {
+        int failures = 0;
+        failures += Tests.testUlpDiff("Math.cosh(double)",
+                                      input, Math.cosh(input),
+                                      expected, ulps);
+        failures += Tests.testUlpDiff("Math.cosh(double)",
+                                      -input, Math.cosh(-input),
+                                      expected, ulps);
+
+        failures += Tests.testUlpDiff("StrictMath.cosh(double)",
+                                      input, StrictMath.cosh(input),
+                                      expected, ulps);
+        failures += Tests.testUlpDiff("StrictMath.cosh(double)",
+                                      -input, StrictMath.cosh(-input),
+                                      expected, ulps);
+        return failures;
+    }
+
+
+    /**
+     * Test accuracy of {Math, StrictMath}.tanh.  The specified
+     * accuracy is 2.5 ulps.
+     *
+     * The defintion of tanh(x) is
+     *
+     * (e^x - e^(-x))/(e^x + e^(-x))
+     *
+     * The series expansion of tanh(x) =
+     *
+     * x - x^3/3 + 2x^5/15 - 17x^7/315 + ...
+     *
+     * Therefore,
+     *
+     * 1. For large values of x tanh(x) ~= signum(x)
+     *
+     * 2. For small values of x, tanh(x) ~= x.
+     *
+     * Additionally, tanh is an odd function; tanh(-x) = -tanh(x).
+     *
+     */
+    static int testTanh() {
+        int failures = 0;
+        /*
+         * Array elements below generated using a quad sinh
+         * implementation.  Rounded to a double, the quad result
+         * *should* be correctly rounded, unless we are quite unlucky.
+         * Assuming the quad value is a correctly rounded double, the
+         * allowed error is 3.0 ulps instead of 2.5 since the quad
+         * value rounded to double can have its own 1/2 ulp error.
+         */
+        double [][] testCases = {
+            // x                tanh(x)
+            {0.0625,            0.06241874674751251449014289119421133},
+            {0.1250,            0.12435300177159620805464727580589271},
+            {0.1875,            0.18533319990813951753211997502482787},
+            {0.2500,            0.24491866240370912927780113149101697},
+            {0.3125,            0.30270972933210848724239738970991712},
+            {0.3750,            0.35835739835078594631936023155315807},
+            {0.4375,            0.41157005567402245143207555859415687},
+            {0.5000,            0.46211715726000975850231848364367256},
+            {0.5625,            0.50982997373525658248931213507053130},
+            {0.6250,            0.55459972234938229399903909532308371},
+            {0.6875,            0.59637355547924233984437303950726939},
+            {0.7500,            0.63514895238728731921443435731249638},
+            {0.8125,            0.67096707420687367394810954721913358},
+            {0.8750,            0.70390560393662106058763026963135371},
+            {0.9375,            0.73407151960434149263991588052503660},
+            {1.0000,            0.76159415595576488811945828260479366},
+            {1.0625,            0.78661881210869761781941794647736081},
+            {1.1250,            0.80930107020178101206077047354332696},
+            {1.1875,            0.82980190998595952708572559629034476},
+            {1.2500,            0.84828363995751289761338764670750445},
+            {1.3125,            0.86490661772074179125443141102709751},
+            {1.3750,            0.87982669965198475596055310881018259},
+            {1.4375,            0.89319334040035153149249598745889365},
+            {1.5000,            0.90514825364486643824230369645649557},
+            {1.5625,            0.91582454416876231820084311814416443},
+            {1.6250,            0.92534622531174107960457166792300374},
+            {1.6875,            0.93382804322259173763570528576138652},
+            {1.7500,            0.94137553849728736226942088377163687},
+            {1.8125,            0.94808528560440629971240651310180052},
+            {1.8750,            0.95404526017994877009219222661968285},
+            {1.9375,            0.95933529331468249183399461756952555},
+            {2.0000,            0.96402758007581688394641372410092317},
+            {2.0625,            0.96818721657637057702714316097855370},
+            {2.1250,            0.97187274591350905151254495374870401},
+            {2.1875,            0.97513669829362836159665586901156483},
+            {2.2500,            0.97802611473881363992272924300618321},
+            {2.3125,            0.98058304703705186541999427134482061},
+            {2.3750,            0.98284502917257603002353801620158861},
+            {2.4375,            0.98484551746427837912703608465407824},
+            {2.5000,            0.98661429815143028888127603923734964},
+            {2.5625,            0.98817786228751240824802592958012269},
+            {2.6250,            0.98955974861288320579361709496051109},
+            {2.6875,            0.99078085564125158320311117560719312},
+            {2.7500,            0.99185972456820774534967078914285035},
+            {2.8125,            0.99281279483715982021711715899682324},
+            {2.8750,            0.99365463431502962099607366282699651},
+            {2.9375,            0.99439814606575805343721743822723671},
+            {3.0000,            0.99505475368673045133188018525548849},
+            {3.0625,            0.99563456710930963835715538507891736},
+            {3.1250,            0.99614653067334504917102591131792951},
+            {3.1875,            0.99659855517712942451966113109487039},
+            {3.2500,            0.99699763548652601693227592643957226},
+            {3.3125,            0.99734995516557367804571991063376923},
+            {3.3750,            0.99766097946988897037219469409451602},
+            {3.4375,            0.99793553792649036103161966894686844},
+            {3.5000,            0.99817789761119870928427335245061171},
+            {3.5625,            0.99839182812874152902001617480606320},
+            {3.6250,            0.99858065920179882368897879066418294},
+            {3.6875,            0.99874733168378115962760304582965538},
+            {3.7500,            0.99889444272615280096784208280487888},
+            {3.8125,            0.99902428575443546808677966295308778},
+            {3.8750,            0.99913888583735077016137617231569011},
+            {3.9375,            0.99924003097049627100651907919688313},
+            {4.0000,            0.99932929973906704379224334434172499},
+            {4.0625,            0.99940808577297384603818654530731215},
+            {4.1250,            0.99947761936180856115470576756499454},
+            {4.1875,            0.99953898655601372055527046497863955},
+            {4.2500,            0.99959314604388958696521068958989891},
+            {4.3125,            0.99964094406130644525586201091350343},
+            {4.3750,            0.99968312756179494813069349082306235},
+            {4.4375,            0.99972035584870534179601447812936151},
+            {4.5000,            0.99975321084802753654050617379050162},
+            {4.5625,            0.99978220617994689112771768489030236},
+            {4.6250,            0.99980779516900105210240981251048167},
+            {4.6875,            0.99983037791655283849546303868853396},
+            {4.7500,            0.99985030754497877753787358852000255},
+            {4.8125,            0.99986789571029070417475400133989992},
+            {4.8750,            0.99988341746867772271011794614780441},
+            {4.9375,            0.99989711557251558205051185882773206},
+            {5.0000,            0.99990920426259513121099044753447306},
+            {5.0625,            0.99991987261554158551063867262784721},
+            {5.1250,            0.99992928749851651137225712249720606},
+            {5.1875,            0.99993759617721206697530526661105307},
+            {5.2500,            0.99994492861777083305830639416802036},
+            {5.3125,            0.99995139951851344080105352145538345},
+            {5.3750,            0.99995711010315817210152906092289064},
+            {5.4375,            0.99996214970350792531554669737676253},
+            {5.5000,            0.99996659715630380963848952941756868},
+            {5.5625,            0.99997052203605101013786592945475432},
+            {5.6250,            0.99997398574306704793434088941484766},
+            {5.6875,            0.99997704246374583929961850444364696},
+            {5.7500,            0.99997974001803825215761760428815437},
+            {5.8125,            0.99998212060739040166557477723121777},
+            {5.8750,            0.99998422147482750993344503195672517},
+            {5.9375,            0.99998607548749972326220227464612338},
+            {6.0000,            0.99998771165079557056434885235523206},
+            {6.0625,            0.99998915556205996764518917496149338},
+            {6.1250,            0.99999042981101021976277974520745310},
+            {6.1875,            0.99999155433311068015449574811497719},
+            {6.2500,            0.99999254672143162687722782398104276},
+            {6.3125,            0.99999342250186907900400800240980139},
+            {6.3750,            0.99999419537602957780612639767025158},
+            {6.4375,            0.99999487743557848265406225515388994},
+            {6.5000,            0.99999547935140419285107893831698753},
+            {6.5625,            0.99999601054055694588617385671796346},
+            {6.6250,            0.99999647931357331502887600387959900},
+            {6.6875,            0.99999689300449080997594368612277442},
+            {6.7500,            0.99999725808558628431084200832778748},
+            {6.8125,            0.99999758026863294516387464046135924},
+            {6.8750,            0.99999786459425991170635407313276785},
+            {6.9375,            0.99999811551081218572759991597586905},
+            {7.0000,            0.99999833694394467173571641595066708},
+            {7.0625,            0.99999853235803894918375164252059190},
+            {7.1250,            0.99999870481040359014665019356422927},
+            {7.1875,            0.99999885699910593255108365463415411},
+            {7.2500,            0.99999899130518359709674536482047025},
+            {7.3125,            0.99999910982989611769943303422227663},
+            {7.3750,            0.99999921442759946591163427422888252},
+            {7.4375,            0.99999930673475777603853435094943258},
+            {7.5000,            0.99999938819554614875054970643513124},
+            {7.5625,            0.99999946008444508183970109263856958},
+            {7.6250,            0.99999952352618001331402589096040117},
+            {7.6875,            0.99999957951331792817413683491979752},
+            {7.7500,            0.99999962892179632633374697389145081},
+            {7.8125,            0.99999967252462750190604116210421169},
+            {7.8750,            0.99999971100399253750324718031574484},
+            {7.9375,            0.99999974496191422474977283863588658},
+            {8.0000,            0.99999977492967588981001883295636840},
+            {8.0625,            0.99999980137613348259726597081723424},
+            {8.1250,            0.99999982471505097353529823063673263},
+            {8.1875,            0.99999984531157382142423402736529911},
+            {8.2500,            0.99999986348794179107425910499030547},
+            {8.3125,            0.99999987952853049895833839645847571},
+            {8.3750,            0.99999989368430056302584289932834041},
+            {8.4375,            0.99999990617672396471542088609051728},
+            {8.5000,            0.99999991720124905211338798152800748},
+            {8.5625,            0.99999992693035839516545287745322387},
+            {8.6250,            0.99999993551626733394129009365703767},
+            {8.6875,            0.99999994309330543951799157347876934},
+            {8.7500,            0.99999994978001814614368429416607424},
+            {8.8125,            0.99999995568102143535399207289008504},
+            {8.8750,            0.99999996088863858914831986187674522},
+            {8.9375,            0.99999996548434461974481685677429908},
+            {9.0000,            0.99999996954004097447930211118358244},
+            {9.0625,            0.99999997311918045901919121395899372},
+            {9.1250,            0.99999997627775997868467948564005257},
+            {9.1875,            0.99999997906519662964368381583648379},
+            {9.2500,            0.99999998152510084671976114264303159},
+            {9.3125,            0.99999998369595870397054673668361266},
+            {9.3750,            0.99999998561173404286033236040150950},
+            {9.4375,            0.99999998730239984852716512979473289},
+            {9.5000,            0.99999998879440718770812040917618843},
+            {9.5625,            0.99999999011109904501789298212541698},
+            {9.6250,            0.99999999127307553219220251303121960},
+            {9.6875,            0.99999999229851618412119275358396363},
+            {9.7500,            0.99999999320346438410630581726217930},
+            {9.8125,            0.99999999400207836827291739324060736},
+            {9.8750,            0.99999999470685273619047001387577653},
+            {9.9375,            0.99999999532881393331131526966058758},
+            {10.0000,           0.99999999587769276361959283713827574},
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            double [] testCase = testCases[i];
+            failures += testTanhCaseWithUlpDiff(testCase[0],
+                                                testCase[1],
+                                                3.0);
+        }
+
+
+        double [][] specialTestCases = {
+            {0.0,                       0.0},
+            {NaNd,                      NaNd},
+            {Double.longBitsToDouble(0x7FF0000000000001L),      NaNd},
+            {Double.longBitsToDouble(0xFFF0000000000001L),      NaNd},
+            {Double.longBitsToDouble(0x7FF8555555555555L),      NaNd},
+            {Double.longBitsToDouble(0xFFF8555555555555L),      NaNd},
+            {Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL),      NaNd},
+            {Double.longBitsToDouble(0xFFFFFFFFFFFFFFFFL),      NaNd},
+            {Double.longBitsToDouble(0x7FFDeadBeef00000L),      NaNd},
+            {Double.longBitsToDouble(0xFFFDeadBeef00000L),      NaNd},
+            {Double.longBitsToDouble(0x7FFCafeBabe00000L),      NaNd},
+            {Double.longBitsToDouble(0xFFFCafeBabe00000L),      NaNd},
+            {Double.POSITIVE_INFINITY,  1.0}
+        };
+
+        for(int i = 0; i < specialTestCases.length; i++) {
+            failures += testTanhCaseWithUlpDiff(specialTestCases[i][0],
+                                                specialTestCases[i][1],
+                                                0.0);
+        }
+
+        // For powers of 2 less than 2^(-27), the second and
+        // subsequent terms of the Taylor series expansion will get
+        // rounded away since |n-n^3| > 53, the binary precision of a
+        // double significand.
+
+        for(int i = DoubleConsts.MIN_SUB_EXPONENT; i < -27; i++) {
+            double d = FpUtils.scalb(2.0, i);
+
+            // Result and expected are the same.
+            failures += testTanhCaseWithUlpDiff(d, d, 2.5);
+        }
+
+        // For values of x larger than 22, tanh(x) is 1.0 in double
+        // floating-point arithmetic.
+
+        for(int i = 22; i < 32; i++) {
+            failures += testTanhCaseWithUlpDiff(i, 1.0, 2.5);
+        }
+
+        for(int i = 5; i <= DoubleConsts.MAX_EXPONENT; i++) {
+            double d = FpUtils.scalb(2.0, i);
+
+            failures += testTanhCaseWithUlpDiff(d, 1.0, 2.5);
+        }
+
+        return failures;
+    }
+
+    public static int testTanhCaseWithTolerance(double input,
+                                                double expected,
+                                                double tolerance) {
+        int failures = 0;
+        failures += Tests.testTolerance("Math.tanh(double",
+                                        input, Math.tanh(input),
+                                        expected, tolerance);
+        failures += Tests.testTolerance("Math.tanh(double",
+                                        -input, Math.tanh(-input),
+                                        -expected, tolerance);
+
+        failures += Tests.testTolerance("StrictMath.tanh(double",
+                                        input, StrictMath.tanh(input),
+                                        expected, tolerance);
+        failures += Tests.testTolerance("StrictMath.tanh(double",
+                                        -input, StrictMath.tanh(-input),
+                                        -expected, tolerance);
+        return failures;
+    }
+
+    public static int testTanhCaseWithUlpDiff(double input,
+                                              double expected,
+                                              double ulps) {
+        int failures = 0;
+
+        failures += Tests.testUlpDiffWithAbsBound("Math.tanh(double)",
+                                                  input, Math.tanh(input),
+                                                  expected, ulps, 1.0);
+        failures += Tests.testUlpDiffWithAbsBound("Math.tanh(double)",
+                                                  -input, Math.tanh(-input),
+                                                  -expected, ulps, 1.0);
+
+        failures += Tests.testUlpDiffWithAbsBound("StrictMath.tanh(double)",
+                                                  input, StrictMath.tanh(input),
+                                                  expected, ulps, 1.0);
+        failures += Tests.testUlpDiffWithAbsBound("StrictMath.tanh(double)",
+                                                  -input, StrictMath.tanh(-input),
+                                                  -expected, ulps, 1.0);
+        return failures;
+    }
+
+
+    public static void main(String argv[]) {
+        int failures = 0;
+
+        failures += testSinh();
+        failures += testCosh();
+        failures += testTanh();
+
+        if (failures > 0) {
+            System.err.println("Testing the hyperbolic functions incurred "
+                               + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Math/HypotTests.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,245 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4851638 4939441
+ * @summary Tests for {Math, StrictMath}.hypot
+ * @author Joseph D. Darcy
+ */
+
+import sun.misc.DoubleConsts;
+import sun.misc.FpUtils;
+
+public class HypotTests {
+    private HypotTests(){}
+
+    static final double infinityD = Double.POSITIVE_INFINITY;
+    static final double NaNd      = Double.NaN;
+
+    /**
+     * Given integers m and n, assuming m < n, the triple (n^2 - m^2,
+     * 2mn, and n^2 + m^2) is a Pythagorean triple with a^2 + b^2 =
+     * c^2.  This methods returns a long array holding the Pythagorean
+     * triple corresponding to the inputs.
+     */
+    static long [] pythagoreanTriple(int m, int n) {
+        long M = m;
+        long N = n;
+        long result[] = new long[3];
+
+
+        result[0] = Math.abs(M*M - N*N);
+        result[1] = Math.abs(2*M*N);
+        result[2] = Math.abs(M*M + N*N);
+
+        return result;
+    }
+
+    static int testHypot() {
+        int failures = 0;
+
+        double [][] testCases = {
+            // Special cases
+            {infinityD,         infinityD,              infinityD},
+            {infinityD,         0.0,                    infinityD},
+            {infinityD,         1.0,                    infinityD},
+            {infinityD,         NaNd,                   infinityD},
+            {NaNd,              NaNd,                   NaNd},
+            {0.0,               NaNd,                   NaNd},
+            {1.0,               NaNd,                   NaNd},
+            {Double.longBitsToDouble(0x7FF0000000000001L),      1.0,    NaNd},
+            {Double.longBitsToDouble(0xFFF0000000000001L),      1.0,    NaNd},
+            {Double.longBitsToDouble(0x7FF8555555555555L),      1.0,    NaNd},
+            {Double.longBitsToDouble(0xFFF8555555555555L),      1.0,    NaNd},
+            {Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL),      1.0,    NaNd},
+            {Double.longBitsToDouble(0xFFFFFFFFFFFFFFFFL),      1.0,    NaNd},
+            {Double.longBitsToDouble(0x7FFDeadBeef00000L),      1.0,    NaNd},
+            {Double.longBitsToDouble(0xFFFDeadBeef00000L),      1.0,    NaNd},
+            {Double.longBitsToDouble(0x7FFCafeBabe00000L),      1.0,    NaNd},
+            {Double.longBitsToDouble(0xFFFCafeBabe00000L),      1.0,    NaNd},
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            failures += testHypotCase(testCases[i][0], testCases[i][1],
+                                      testCases[i][2]);
+        }
+
+        // Verify hypot(x, 0.0) is close to x over the entire exponent
+        // range.
+        for(int i = DoubleConsts.MIN_SUB_EXPONENT;
+            i <= DoubleConsts.MAX_EXPONENT;
+            i++) {
+            double input = FpUtils.scalb(2, i);
+            failures += testHypotCase(input, 0.0, input);
+        }
+
+
+        // Test Pythagorean triples
+
+        // Small ones
+        for(int m = 1; m < 10; m++) {
+            for(int n = m+1; n < 11; n++) {
+                long [] result = pythagoreanTriple(m, n);
+                failures += testHypotCase(result[0], result[1], result[2]);
+            }
+        }
+
+        // Big ones
+        for(int m = 100000; m < 100100; m++) {
+            for(int n = m+100000; n < 200200; n++) {
+                long [] result = pythagoreanTriple(m, n);
+                failures += testHypotCase(result[0], result[1], result[2]);
+            }
+        }
+
+        // Approaching overflow tests
+
+        /*
+         * Create a random value r with an large-ish exponent.  The
+         * result of hypot(3*r, 4*r) should be approximately 5*r. (The
+         * computation of 4*r is exact since it just changes the
+         * exponent).  While the exponent of r is less than or equal
+         * to (MAX_EXPONENT - 3), the computation should not overflow.
+         */
+        java.util.Random rand = new java.util.Random();
+        for(int i = 0; i < 1000; i++) {
+            double d = rand.nextDouble();
+            // Scale d to have an exponent equal to MAX_EXPONENT -15
+            d = FpUtils.scalb(d, DoubleConsts.MAX_EXPONENT
+                                 -15 - FpUtils.ilogb(d));
+            for(int j = 0; j <= 13; j += 1) {
+                failures += testHypotCase(3*d, 4*d, 5*d, 2.5);
+                d *= 2.0; // increase exponent by 1
+            }
+        }
+
+        // Test for monotonicity failures.  Fix one argument and test
+        // two numbers before and two numbers after each chosen value;
+        // i.e.
+        //
+        // pcNeighbors[] =
+        // {nextDown(nextDown(pc)),
+        // nextDown(pc),
+        // pc,
+        // nextUp(pc),
+        // nextUp(nextUp(pc))}
+        //
+        // and we test that hypot(pcNeighbors[i]) <= hypot(pcNeighbors[i+1])
+        {
+            double pcNeighbors[] = new double[5];
+            double pcNeighborsHypot[] = new double[5];
+            double pcNeighborsStrictHypot[] = new double[5];
+
+
+            for(int i = -18; i <= 18; i++) {
+                double pc = FpUtils.scalb(1.0, i);
+
+                pcNeighbors[2] = pc;
+                pcNeighbors[1] = FpUtils.nextDown(pc);
+                pcNeighbors[0] = FpUtils.nextDown(pcNeighbors[1]);
+                pcNeighbors[3] = FpUtils.nextUp(pc);
+                pcNeighbors[4] = FpUtils.nextUp(pcNeighbors[3]);
+
+                for(int j = 0; j < pcNeighbors.length; j++) {
+                    pcNeighborsHypot[j]       =       Math.hypot(2.0, pcNeighbors[j]);
+                    pcNeighborsStrictHypot[j] = StrictMath.hypot(2.0, pcNeighbors[j]);
+                }
+
+                for(int j = 0; j < pcNeighborsHypot.length-1; j++) {
+                    if(pcNeighborsHypot[j] >  pcNeighborsHypot[j+1] ) {
+                        failures++;
+                        System.err.println("Monotonicity failure for Math.hypot on " +
+                                          pcNeighbors[j] + " and "  +
+                                          pcNeighbors[j+1] + "\n\treturned " +
+                                          pcNeighborsHypot[j] + " and " +
+                                          pcNeighborsHypot[j+1] );
+                    }
+
+                    if(pcNeighborsStrictHypot[j] >  pcNeighborsStrictHypot[j+1] ) {
+                        failures++;
+                        System.err.println("Monotonicity failure for StrictMath.hypot on " +
+                                          pcNeighbors[j] + " and "  +
+                                          pcNeighbors[j+1] + "\n\treturned " +
+                                          pcNeighborsStrictHypot[j] + " and " +
+                                          pcNeighborsStrictHypot[j+1] );
+                    }
+
+
+                }
+
+            }
+        }
+
+
+        return failures;
+    }
+
+    static int testHypotCase(double input1, double input2, double expected) {
+        return testHypotCase(input1,input2, expected, 1);
+    }
+
+    static int testHypotCase(double input1, double input2, double expected,
+                             double ulps) {
+        int failures = 0;
+        if (expected < 0.0) {
+            throw new AssertionError("Result of hypot must be greater than " +
+                                     "or equal to zero");
+        }
+
+        // Test Math and StrictMath methods with no inputs negated,
+        // each input negated singly, and both inputs negated.  Also
+        // test inputs in reversed order.
+
+        for(int i = -1; i <= 1; i+=2) {
+            for(int j = -1; j <= 1; j+=2) {
+                double x = i * input1;
+                double y = j * input2;
+                failures += Tests.testUlpDiff("Math.hypot", x, y,
+                                              Math.hypot(x, y), expected, ulps);
+                failures += Tests.testUlpDiff("Math.hypot", y, x,
+                                              Math.hypot(y, x ), expected, ulps);
+
+                failures += Tests.testUlpDiff("StrictMath.hypot", x, y,
+                                              StrictMath.hypot(x, y), expected, ulps);
+                failures += Tests.testUlpDiff("StrictMath.hypot", y, x,
+                                              StrictMath.hypot(y, x), expected, ulps);
+            }
+        }
+
+        return failures;
+    }
+
+    public static void main(String argv[]) {
+        int failures = 0;
+
+        failures += testHypot();
+
+        if (failures > 0) {
+            System.err.println("Testing the hypot incurred "
+                               + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Math/IeeeRecommendedTests.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,1705 @@
+/*
+ * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4860891 4826732 4780454 4939441 4826652
+ * @summary Tests for IEEE 754[R] recommended functions and similar methods
+ * @author Joseph D. Darcy
+ * @compile -source 1.5 IeeeRecommendedTests.java
+ * @run main IeeeRecommendedTests
+ */
+
+import sun.misc.FpUtils;
+import sun.misc.DoubleConsts;
+import sun.misc.FloatConsts;
+
+public class IeeeRecommendedTests {
+    private IeeeRecommendedTests(){}
+
+    static final float  NaNf = Float.NaN;
+    static final double NaNd = Double.NaN;
+    static final float  infinityF = Float.POSITIVE_INFINITY;
+    static final double infinityD = Double.POSITIVE_INFINITY;
+
+    static final float  Float_MAX_VALUEmm       = 0x1.fffffcP+127f;
+    static final float  Float_MAX_SUBNORMAL     = 0x0.fffffeP-126f;
+    static final float  Float_MAX_SUBNORMALmm   = 0x0.fffffcP-126f;
+
+    static final double Double_MAX_VALUEmm      = 0x1.ffffffffffffeP+1023;
+    static final double Double_MAX_SUBNORMAL    = 0x0.fffffffffffffP-1022;
+    static final double Double_MAX_SUBNORMALmm  = 0x0.ffffffffffffeP-1022;
+
+    // Initialize shared random number generator
+    static java.util.Random rand = new java.util.Random();
+
+    /**
+     * Returns a floating-point power of two in the normal range.
+     */
+    static double powerOfTwoD(int n) {
+        return Double.longBitsToDouble((((long)n + (long)DoubleConsts.MAX_EXPONENT) <<
+                                        (DoubleConsts.SIGNIFICAND_WIDTH-1))
+                                       & DoubleConsts.EXP_BIT_MASK);
+    }
+
+    /**
+     * Returns a floating-point power of two in the normal range.
+     */
+    static float powerOfTwoF(int n) {
+        return Float.intBitsToFloat(((n + FloatConsts.MAX_EXPONENT) <<
+                                     (FloatConsts.SIGNIFICAND_WIDTH-1))
+                                    & FloatConsts.EXP_BIT_MASK);
+    }
+
+    /* ******************** getExponent tests ****************************** */
+
+    /*
+     * The tests for getExponent should test the special values (NaN, +/-
+     * infinity, etc.), test the endpoints of each binade (set of
+     * floating-point values with the same exponent), and for good
+     * measure, test some random values within each binade.  Testing
+     * the endpoints of each binade includes testing both positive and
+     * negative numbers.  Subnormal values with different normalized
+     * exponents should be tested too.  Both Math and StrictMath
+     * methods should return the same results.
+     */
+
+    /*
+     * Test Math.getExponent and StrictMath.getExponent with +d and -d.
+     */
+    static int testGetExponentCase(float f, int expected) {
+        float minus_f = -f;
+        int failures=0;
+
+        failures+=Tests.test("Math.getExponent(float)", f,
+                             Math.getExponent(f), expected);
+        failures+=Tests.test("Math.getExponent(float)", minus_f,
+                             Math.getExponent(minus_f), expected);
+
+        failures+=Tests.test("StrictMath.getExponent(float)", f,
+                             StrictMath.getExponent(f), expected);
+        failures+=Tests.test("StrictMath.getExponent(float)", minus_f,
+                             StrictMath.getExponent(minus_f), expected);
+        return failures;
+    }
+
+    /*
+     * Test Math.getExponent and StrictMath.getExponent with +d and -d.
+     */
+    static int testGetExponentCase(double d, int expected) {
+        double minus_d = -d;
+        int failures=0;
+
+        failures+=Tests.test("Math.getExponent(double)", d,
+                             Math.getExponent(d), expected);
+        failures+=Tests.test("Math.getExponent(double)", minus_d,
+                             Math.getExponent(minus_d), expected);
+
+        failures+=Tests.test("StrictMath.getExponent(double)", d,
+                             StrictMath.getExponent(d), expected);
+        failures+=Tests.test("StrictMath.getExponent(double)", minus_d,
+                             StrictMath.getExponent(minus_d), expected);
+        return failures;
+    }
+
+    public static int testFloatGetExponent() {
+        int failures = 0;
+        float [] specialValues = {NaNf,
+                                   Float.POSITIVE_INFINITY,
+                                   +0.0f,
+                                  +1.0f,
+                                  +2.0f,
+                                  +16.0f,
+                                  +Float.MIN_VALUE,
+                                  +Float_MAX_SUBNORMAL,
+                                  +FloatConsts.MIN_NORMAL,
+                                  +Float.MAX_VALUE
+        };
+
+        int [] specialResults = {Float.MAX_EXPONENT + 1, // NaN results
+                                 Float.MAX_EXPONENT + 1, // Infinite results
+                                 Float.MIN_EXPONENT - 1, // Zero results
+                                 0,
+                                 1,
+                                 4,
+                                 FloatConsts.MIN_EXPONENT - 1,
+                                 -FloatConsts.MAX_EXPONENT,
+                                 FloatConsts.MIN_EXPONENT,
+                                 FloatConsts.MAX_EXPONENT
+        };
+
+        // Special value tests
+        for(int i = 0; i < specialValues.length; i++) {
+            failures += testGetExponentCase(specialValues[i], specialResults[i]);
+        }
+
+
+        // Normal exponent tests
+        for(int i = FloatConsts.MIN_EXPONENT; i <= FloatConsts.MAX_EXPONENT; i++) {
+            int result;
+
+            // Create power of two
+            float po2 = powerOfTwoF(i);
+
+            failures += testGetExponentCase(po2, i);
+
+            // Generate some random bit patterns for the significand
+            for(int j = 0; j < 10; j++) {
+                int randSignif = rand.nextInt();
+                float randFloat;
+
+                randFloat = Float.intBitsToFloat( // Exponent
+                                                 (Float.floatToIntBits(po2)&
+                                                  (~FloatConsts.SIGNIF_BIT_MASK)) |
+                                                 // Significand
+                                                 (randSignif &
+                                                  FloatConsts.SIGNIF_BIT_MASK) );
+
+                failures += testGetExponentCase(randFloat, i);
+            }
+
+            if (i > FloatConsts.MIN_EXPONENT) {
+                float po2minus = FpUtils.nextAfter(po2,
+                                                 Float.NEGATIVE_INFINITY);
+                failures += testGetExponentCase(po2minus, i-1);
+            }
+        }
+
+        // Subnormal exponent tests
+
+        /*
+         * Start with MIN_VALUE, left shift, test high value, low
+         * values, and random in between.
+         *
+         * Use nextAfter to calculate, high value of previous binade,
+         * loop count i will indicate how many random bits, if any are
+         * needed.
+         */
+
+        float top=Float.MIN_VALUE;
+        for( int i = 1;
+            i < FloatConsts.SIGNIFICAND_WIDTH;
+            i++, top *= 2.0f) {
+
+            failures += testGetExponentCase(top,
+                                            FloatConsts.MIN_EXPONENT - 1);
+
+            // Test largest value in next smaller binade
+            if (i >= 3) {// (i == 1) would test 0.0;
+                         // (i == 2) would just retest MIN_VALUE
+                testGetExponentCase(FpUtils.nextAfter(top, 0.0f),
+                                    FloatConsts.MIN_EXPONENT - 1);
+
+                if( i >= 10) {
+                    // create a bit mask with (i-1) 1's in the low order
+                    // bits
+                    int mask = ~((~0)<<(i-1));
+                    float randFloat = Float.intBitsToFloat( // Exponent
+                                                 Float.floatToIntBits(top) |
+                                                 // Significand
+                                                 (rand.nextInt() & mask ) ) ;
+
+                    failures += testGetExponentCase(randFloat,
+                                                    FloatConsts.MIN_EXPONENT - 1);
+                }
+            }
+        }
+
+        return failures;
+    }
+
+
+    public static int testDoubleGetExponent() {
+        int failures = 0;
+        double [] specialValues = {NaNd,
+                                   infinityD,
+                                   +0.0,
+                                   +1.0,
+                                   +2.0,
+                                   +16.0,
+                                   +Double.MIN_VALUE,
+                                   +Double_MAX_SUBNORMAL,
+                                   +DoubleConsts.MIN_NORMAL,
+                                   +Double.MAX_VALUE
+        };
+
+        int [] specialResults = {Double.MAX_EXPONENT + 1, // NaN results
+                                 Double.MAX_EXPONENT + 1, // Infinite results
+                                 Double.MIN_EXPONENT - 1, // Zero results
+                                 0,
+                                 1,
+                                 4,
+                                 DoubleConsts.MIN_EXPONENT - 1,
+                                 -DoubleConsts.MAX_EXPONENT,
+                                 DoubleConsts.MIN_EXPONENT,
+                                 DoubleConsts.MAX_EXPONENT
+        };
+
+        // Special value tests
+        for(int i = 0; i < specialValues.length; i++) {
+            failures += testGetExponentCase(specialValues[i], specialResults[i]);
+        }
+
+
+        // Normal exponent tests
+        for(int i = DoubleConsts.MIN_EXPONENT; i <= DoubleConsts.MAX_EXPONENT; i++) {
+            int result;
+
+            // Create power of two
+            double po2 = powerOfTwoD(i);
+
+            failures += testGetExponentCase(po2, i);
+
+            // Generate some random bit patterns for the significand
+            for(int j = 0; j < 10; j++) {
+                long randSignif = rand.nextLong();
+                double randFloat;
+
+                randFloat = Double.longBitsToDouble( // Exponent
+                                                 (Double.doubleToLongBits(po2)&
+                                                  (~DoubleConsts.SIGNIF_BIT_MASK)) |
+                                                 // Significand
+                                                 (randSignif &
+                                                  DoubleConsts.SIGNIF_BIT_MASK) );
+
+                failures += testGetExponentCase(randFloat, i);
+            }
+
+            if (i > DoubleConsts.MIN_EXPONENT) {
+                double po2minus = FpUtils.nextAfter(po2,
+                                                    Double.NEGATIVE_INFINITY);
+                failures += testGetExponentCase(po2minus, i-1);
+            }
+        }
+
+        // Subnormal exponent tests
+
+        /*
+         * Start with MIN_VALUE, left shift, test high value, low
+         * values, and random in between.
+         *
+         * Use nextAfter to calculate, high value of previous binade;
+         * loop count i will indicate how many random bits, if any are
+         * needed.
+         */
+
+        double top=Double.MIN_VALUE;
+        for( int i = 1;
+            i < DoubleConsts.SIGNIFICAND_WIDTH;
+            i++, top *= 2.0f) {
+
+            failures += testGetExponentCase(top,
+                                            DoubleConsts.MIN_EXPONENT - 1);
+
+            // Test largest value in next smaller binade
+            if (i >= 3) {// (i == 1) would test 0.0;
+                         // (i == 2) would just retest MIN_VALUE
+                testGetExponentCase(FpUtils.nextAfter(top, 0.0),
+                                    DoubleConsts.MIN_EXPONENT - 1);
+
+                if( i >= 10) {
+                    // create a bit mask with (i-1) 1's in the low order
+                    // bits
+                    long mask = ~((~0L)<<(i-1));
+                    double randFloat = Double.longBitsToDouble( // Exponent
+                                                 Double.doubleToLongBits(top) |
+                                                 // Significand
+                                                 (rand.nextLong() & mask ) ) ;
+
+                    failures += testGetExponentCase(randFloat,
+                                                    DoubleConsts.MIN_EXPONENT - 1);
+                }
+            }
+        }
+
+        return failures;
+    }
+
+
+    /* ******************** nextAfter tests ****************************** */
+
+    static int testNextAfterCase(float start, double direction, float expected) {
+        int failures=0;
+        float minus_start = -start;
+        double minus_direction = -direction;
+        float minus_expected = -expected;
+
+        failures+=Tests.test("Math.nextAfter(float,double)", start, direction,
+                             Math.nextAfter(start, direction), expected);
+        failures+=Tests.test("Math.nextAfter(float,double)", minus_start, minus_direction,
+                             Math.nextAfter(minus_start, minus_direction), minus_expected);
+
+        failures+=Tests.test("StrictMath.nextAfter(float,double)", start, direction,
+                             StrictMath.nextAfter(start, direction), expected);
+        failures+=Tests.test("StrictMath.nextAfter(float,double)", minus_start, minus_direction,
+                             StrictMath.nextAfter(minus_start, minus_direction), minus_expected);
+        return failures;
+    }
+
+    static int testNextAfterCase(double start, double direction, double expected) {
+        int failures=0;
+
+        double minus_start = -start;
+        double minus_direction = -direction;
+        double minus_expected = -expected;
+
+        failures+=Tests.test("Math.nextAfter(double,double)", start, direction,
+                             Math.nextAfter(start, direction), expected);
+        failures+=Tests.test("Math.nextAfter(double,double)", minus_start, minus_direction,
+                             Math.nextAfter(minus_start, minus_direction), minus_expected);
+
+        failures+=Tests.test("StrictMath.nextAfter(double,double)", start, direction,
+                             StrictMath.nextAfter(start, direction), expected);
+        failures+=Tests.test("StrictMath.nextAfter(double,double)", minus_start, minus_direction,
+                             StrictMath.nextAfter(minus_start, minus_direction), minus_expected);
+        return failures;
+    }
+
+    public static int testFloatNextAfter() {
+        int failures=0;
+
+        /*
+         * Each row of the testCases matrix represents one test case
+         * for nexAfter; given the input of the first two columns, the
+         * result in the last column is expected.
+         */
+        float [][] testCases  = {
+            {NaNf,              NaNf,                   NaNf},
+            {NaNf,              0.0f,                   NaNf},
+            {0.0f,              NaNf,                   NaNf},
+            {NaNf,              infinityF,              NaNf},
+            {infinityF,         NaNf,                   NaNf},
+
+            {infinityF,         infinityF,              infinityF},
+            {infinityF,         -infinityF,             Float.MAX_VALUE},
+            {infinityF,         0.0f,                   Float.MAX_VALUE},
+
+            {Float.MAX_VALUE,   infinityF,              infinityF},
+            {Float.MAX_VALUE,   -infinityF,             Float_MAX_VALUEmm},
+            {Float.MAX_VALUE,   Float.MAX_VALUE,        Float.MAX_VALUE},
+            {Float.MAX_VALUE,   0.0f,                   Float_MAX_VALUEmm},
+
+            {Float_MAX_VALUEmm, Float.MAX_VALUE,        Float.MAX_VALUE},
+            {Float_MAX_VALUEmm, infinityF,              Float.MAX_VALUE},
+            {Float_MAX_VALUEmm, Float_MAX_VALUEmm,      Float_MAX_VALUEmm},
+
+            {FloatConsts.MIN_NORMAL,    infinityF,              FloatConsts.MIN_NORMAL+
+                                                                Float.MIN_VALUE},
+            {FloatConsts.MIN_NORMAL,    -infinityF,             Float_MAX_SUBNORMAL},
+            {FloatConsts.MIN_NORMAL,    1.0f,                   FloatConsts.MIN_NORMAL+
+                                                                Float.MIN_VALUE},
+            {FloatConsts.MIN_NORMAL,    -1.0f,                  Float_MAX_SUBNORMAL},
+            {FloatConsts.MIN_NORMAL,    FloatConsts.MIN_NORMAL, FloatConsts.MIN_NORMAL},
+
+            {Float_MAX_SUBNORMAL,       FloatConsts.MIN_NORMAL, FloatConsts.MIN_NORMAL},
+            {Float_MAX_SUBNORMAL,       Float_MAX_SUBNORMAL,    Float_MAX_SUBNORMAL},
+            {Float_MAX_SUBNORMAL,       0.0f,                   Float_MAX_SUBNORMALmm},
+
+            {Float_MAX_SUBNORMALmm,     Float_MAX_SUBNORMAL,    Float_MAX_SUBNORMAL},
+            {Float_MAX_SUBNORMALmm,     0.0f,                   Float_MAX_SUBNORMALmm-Float.MIN_VALUE},
+            {Float_MAX_SUBNORMALmm,     Float_MAX_SUBNORMALmm,  Float_MAX_SUBNORMALmm},
+
+            {Float.MIN_VALUE,   0.0f,                   0.0f},
+            {-Float.MIN_VALUE,  0.0f,                   -0.0f},
+            {Float.MIN_VALUE,   Float.MIN_VALUE,        Float.MIN_VALUE},
+            {Float.MIN_VALUE,   1.0f,                   2*Float.MIN_VALUE},
+
+            // Make sure zero behavior is tested
+            {0.0f,              0.0f,                   0.0f},
+            {0.0f,              -0.0f,                  -0.0f},
+            {-0.0f,             0.0f,                   0.0f},
+            {-0.0f,             -0.0f,                  -0.0f},
+            {0.0f,              infinityF,              Float.MIN_VALUE},
+            {0.0f,              -infinityF,             -Float.MIN_VALUE},
+            {-0.0f,             infinityF,              Float.MIN_VALUE},
+            {-0.0f,             -infinityF,             -Float.MIN_VALUE},
+            {0.0f,              Float.MIN_VALUE,        Float.MIN_VALUE},
+            {0.0f,              -Float.MIN_VALUE,       -Float.MIN_VALUE},
+            {-0.0f,             Float.MIN_VALUE,        Float.MIN_VALUE},
+            {-0.0f,             -Float.MIN_VALUE,       -Float.MIN_VALUE}
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            failures += testNextAfterCase(testCases[i][0], testCases[i][1],
+                                          testCases[i][2]);
+        }
+
+        return failures;
+    }
+
+    public static int testDoubleNextAfter() {
+        int failures =0;
+
+        /*
+         * Each row of the testCases matrix represents one test case
+         * for nexAfter; given the input of the first two columns, the
+         * result in the last column is expected.
+         */
+        double [][] testCases  = {
+            {NaNd,              NaNd,                   NaNd},
+            {NaNd,              0.0d,                   NaNd},
+            {0.0d,              NaNd,                   NaNd},
+            {NaNd,              infinityD,              NaNd},
+            {infinityD,         NaNd,                   NaNd},
+
+            {infinityD,         infinityD,              infinityD},
+            {infinityD,         -infinityD,             Double.MAX_VALUE},
+            {infinityD,         0.0d,                   Double.MAX_VALUE},
+
+            {Double.MAX_VALUE,  infinityD,              infinityD},
+            {Double.MAX_VALUE,  -infinityD,             Double_MAX_VALUEmm},
+            {Double.MAX_VALUE,  Double.MAX_VALUE,       Double.MAX_VALUE},
+            {Double.MAX_VALUE,  0.0d,                   Double_MAX_VALUEmm},
+
+            {Double_MAX_VALUEmm,        Double.MAX_VALUE,       Double.MAX_VALUE},
+            {Double_MAX_VALUEmm,        infinityD,              Double.MAX_VALUE},
+            {Double_MAX_VALUEmm,        Double_MAX_VALUEmm,     Double_MAX_VALUEmm},
+
+            {DoubleConsts.MIN_NORMAL,   infinityD,              DoubleConsts.MIN_NORMAL+
+                                                                Double.MIN_VALUE},
+            {DoubleConsts.MIN_NORMAL,   -infinityD,             Double_MAX_SUBNORMAL},
+            {DoubleConsts.MIN_NORMAL,   1.0f,                   DoubleConsts.MIN_NORMAL+
+                                                                Double.MIN_VALUE},
+            {DoubleConsts.MIN_NORMAL,   -1.0f,                  Double_MAX_SUBNORMAL},
+            {DoubleConsts.MIN_NORMAL,   DoubleConsts.MIN_NORMAL,DoubleConsts.MIN_NORMAL},
+
+            {Double_MAX_SUBNORMAL,      DoubleConsts.MIN_NORMAL,DoubleConsts.MIN_NORMAL},
+            {Double_MAX_SUBNORMAL,      Double_MAX_SUBNORMAL,   Double_MAX_SUBNORMAL},
+            {Double_MAX_SUBNORMAL,      0.0d,                   Double_MAX_SUBNORMALmm},
+
+            {Double_MAX_SUBNORMALmm,    Double_MAX_SUBNORMAL,   Double_MAX_SUBNORMAL},
+            {Double_MAX_SUBNORMALmm,    0.0d,                   Double_MAX_SUBNORMALmm-Double.MIN_VALUE},
+            {Double_MAX_SUBNORMALmm,    Double_MAX_SUBNORMALmm, Double_MAX_SUBNORMALmm},
+
+            {Double.MIN_VALUE,  0.0d,                   0.0d},
+            {-Double.MIN_VALUE, 0.0d,                   -0.0d},
+            {Double.MIN_VALUE,  Double.MIN_VALUE,       Double.MIN_VALUE},
+            {Double.MIN_VALUE,  1.0f,                   2*Double.MIN_VALUE},
+
+            // Make sure zero behavior is tested
+            {0.0d,              0.0d,                   0.0d},
+            {0.0d,              -0.0d,                  -0.0d},
+            {-0.0d,             0.0d,                   0.0d},
+            {-0.0d,             -0.0d,                  -0.0d},
+            {0.0d,              infinityD,              Double.MIN_VALUE},
+            {0.0d,              -infinityD,             -Double.MIN_VALUE},
+            {-0.0d,             infinityD,              Double.MIN_VALUE},
+            {-0.0d,             -infinityD,             -Double.MIN_VALUE},
+            {0.0d,              Double.MIN_VALUE,       Double.MIN_VALUE},
+            {0.0d,              -Double.MIN_VALUE,      -Double.MIN_VALUE},
+            {-0.0d,             Double.MIN_VALUE,       Double.MIN_VALUE},
+            {-0.0d,             -Double.MIN_VALUE,      -Double.MIN_VALUE}
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            failures += testNextAfterCase(testCases[i][0], testCases[i][1],
+                                          testCases[i][2]);
+        }
+        return failures;
+    }
+
+    /* ******************** nextUp tests ********************************* */
+
+    public static int testFloatNextUp() {
+        int failures=0;
+
+        /*
+         * Each row of testCases represents one test case for nextUp;
+         * the first column is the input and the second column is the
+         * expected result.
+         */
+        float testCases [][] = {
+            {NaNf,                      NaNf},
+            {-infinityF,                -Float.MAX_VALUE},
+            {-Float.MAX_VALUE,          -Float_MAX_VALUEmm},
+            {-FloatConsts.MIN_NORMAL,   -Float_MAX_SUBNORMAL},
+            {-Float_MAX_SUBNORMAL,      -Float_MAX_SUBNORMALmm},
+            {-Float.MIN_VALUE,          -0.0f},
+            {-0.0f,                     Float.MIN_VALUE},
+            {+0.0f,                     Float.MIN_VALUE},
+            {Float.MIN_VALUE,           Float.MIN_VALUE*2},
+            {Float_MAX_SUBNORMALmm,     Float_MAX_SUBNORMAL},
+            {Float_MAX_SUBNORMAL,       FloatConsts.MIN_NORMAL},
+            {FloatConsts.MIN_NORMAL,    FloatConsts.MIN_NORMAL+Float.MIN_VALUE},
+            {Float_MAX_VALUEmm,         Float.MAX_VALUE},
+            {Float.MAX_VALUE,           infinityF},
+            {infinityF,                 infinityF}
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            failures+=Tests.test("Math.nextUp(float)",
+                                 testCases[i][0], Math.nextUp(testCases[i][0]), testCases[i][1]);
+
+            failures+=Tests.test("StrictMath.nextUp(float)",
+                                 testCases[i][0], StrictMath.nextUp(testCases[i][0]), testCases[i][1]);
+        }
+
+        return failures;
+    }
+
+
+    public static int testDoubleNextUp() {
+        int failures=0;
+
+        /*
+         * Each row of testCases represents one test case for nextUp;
+         * the first column is the input and the second column is the
+         * expected result.
+         */
+        double testCases [][] = {
+            {NaNd,                      NaNd},
+            {-infinityD,                -Double.MAX_VALUE},
+            {-Double.MAX_VALUE,         -Double_MAX_VALUEmm},
+            {-DoubleConsts.MIN_NORMAL,  -Double_MAX_SUBNORMAL},
+            {-Double_MAX_SUBNORMAL,     -Double_MAX_SUBNORMALmm},
+            {-Double.MIN_VALUE,         -0.0d},
+            {-0.0d,                     Double.MIN_VALUE},
+            {+0.0d,                     Double.MIN_VALUE},
+            {Double.MIN_VALUE,          Double.MIN_VALUE*2},
+            {Double_MAX_SUBNORMALmm,    Double_MAX_SUBNORMAL},
+            {Double_MAX_SUBNORMAL,      DoubleConsts.MIN_NORMAL},
+            {DoubleConsts.MIN_NORMAL,   DoubleConsts.MIN_NORMAL+Double.MIN_VALUE},
+            {Double_MAX_VALUEmm,        Double.MAX_VALUE},
+            {Double.MAX_VALUE,          infinityD},
+            {infinityD,                 infinityD}
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            failures+=Tests.test("Math.nextUp(double)",
+                                 testCases[i][0], Math.nextUp(testCases[i][0]), testCases[i][1]);
+
+            failures+=Tests.test("StrictMath.nextUp(double)",
+                                 testCases[i][0], StrictMath.nextUp(testCases[i][0]), testCases[i][1]);
+        }
+
+        return failures;
+    }
+
+    /* ******************** nextDown tests ********************************* */
+
+    public static int testFloatNextDown() {
+        int failures=0;
+
+        /*
+         * Each row of testCases represents one test case for nextDown;
+         * the first column is the input and the second column is the
+         * expected result.
+         */
+        float testCases [][] = {
+            {NaNf,                      NaNf},
+            {-infinityF,                -infinityF},
+            {-Float.MAX_VALUE,          -infinityF},
+            {-Float_MAX_VALUEmm,        -Float.MAX_VALUE},
+            {-Float_MAX_SUBNORMAL,      -FloatConsts.MIN_NORMAL},
+            {-Float_MAX_SUBNORMALmm,    -Float_MAX_SUBNORMAL},
+            {-0.0f,                     -Float.MIN_VALUE},
+            {+0.0f,                     -Float.MIN_VALUE},
+            {Float.MIN_VALUE,           0.0f},
+            {Float.MIN_VALUE*2,         Float.MIN_VALUE},
+            {Float_MAX_SUBNORMAL,       Float_MAX_SUBNORMALmm},
+            {FloatConsts.MIN_NORMAL,    Float_MAX_SUBNORMAL},
+            {FloatConsts.MIN_NORMAL+
+             Float.MIN_VALUE,           FloatConsts.MIN_NORMAL},
+            {Float.MAX_VALUE,           Float_MAX_VALUEmm},
+            {infinityF,                 Float.MAX_VALUE},
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            failures+=Tests.test("FpUtils.nextDown(float)",
+                                 testCases[i][0], FpUtils.nextDown(testCases[i][0]), testCases[i][1]);
+        }
+
+        return failures;
+    }
+
+
+    public static int testDoubleNextDown() {
+        int failures=0;
+
+        /*
+         * Each row of testCases represents one test case for nextDown;
+         * the first column is the input and the second column is the
+         * expected result.
+         */
+        double testCases [][] = {
+            {NaNd,                      NaNd},
+            {-infinityD,                -infinityD},
+            {-Double.MAX_VALUE,         -infinityD},
+            {-Double_MAX_VALUEmm,       -Double.MAX_VALUE},
+            {-Double_MAX_SUBNORMAL,     -DoubleConsts.MIN_NORMAL},
+            {-Double_MAX_SUBNORMALmm,   -Double_MAX_SUBNORMAL},
+            {-0.0d,                     -Double.MIN_VALUE},
+            {+0.0d,                     -Double.MIN_VALUE},
+            {Double.MIN_VALUE,          0.0d},
+            {Double.MIN_VALUE*2,        Double.MIN_VALUE},
+            {Double_MAX_SUBNORMAL,      Double_MAX_SUBNORMALmm},
+            {DoubleConsts.MIN_NORMAL,   Double_MAX_SUBNORMAL},
+            {DoubleConsts.MIN_NORMAL+
+             Double.MIN_VALUE,          DoubleConsts.MIN_NORMAL},
+            {Double.MAX_VALUE,          Double_MAX_VALUEmm},
+            {infinityD,                 Double.MAX_VALUE},
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            failures+=Tests.test("FpUtils.nextDown(double)",
+                                 testCases[i][0], FpUtils.nextDown(testCases[i][0]), testCases[i][1]);
+        }
+
+        return failures;
+    }
+
+
+    /* ********************** boolean tests ****************************** */
+
+    /*
+     * Combined tests for boolean functions, isFinite, isInfinite,
+     * isNaN, isUnordered.
+     */
+
+    public static int testFloatBooleanMethods() {
+        int failures = 0;
+
+        float testCases [] = {
+            NaNf,
+            -infinityF,
+            infinityF,
+            -Float.MAX_VALUE,
+            -3.0f,
+            -1.0f,
+            -FloatConsts.MIN_NORMAL,
+            -Float_MAX_SUBNORMALmm,
+            -Float_MAX_SUBNORMAL,
+            -Float.MIN_VALUE,
+            -0.0f,
+            +0.0f,
+            Float.MIN_VALUE,
+            Float_MAX_SUBNORMALmm,
+            Float_MAX_SUBNORMAL,
+            FloatConsts.MIN_NORMAL,
+            1.0f,
+            3.0f,
+            Float_MAX_VALUEmm,
+            Float.MAX_VALUE
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            // isNaN
+            failures+=Tests.test("FpUtils.isNaN(float)", testCases[i],
+                                 FpUtils.isNaN(testCases[i]), (i ==0));
+
+            // isFinite
+            failures+=Tests.test("FpUtils.isFinite(float)", testCases[i],
+                                 FpUtils.isFinite(testCases[i]), (i >= 3));
+
+            // isInfinite
+            failures+=Tests.test("FpUtils.isInfinite(float)", testCases[i],
+                                 FpUtils.isInfinite(testCases[i]), (i==1 || i==2));
+
+            // isUnorderd
+            for(int j = 0; j < testCases.length; j++) {
+                failures+=Tests.test("FpUtils.isUnordered(float, float)", testCases[i],testCases[j],
+                                     FpUtils.isUnordered(testCases[i],testCases[j]), (i==0 || j==0));
+            }
+        }
+
+        return failures;
+    }
+
+    public static int testDoubleBooleanMethods() {
+        int failures = 0;
+        boolean result = false;
+
+        double testCases [] = {
+            NaNd,
+            -infinityD,
+            infinityD,
+            -Double.MAX_VALUE,
+            -3.0d,
+            -1.0d,
+            -DoubleConsts.MIN_NORMAL,
+            -Double_MAX_SUBNORMALmm,
+            -Double_MAX_SUBNORMAL,
+            -Double.MIN_VALUE,
+            -0.0d,
+            +0.0d,
+            Double.MIN_VALUE,
+            Double_MAX_SUBNORMALmm,
+            Double_MAX_SUBNORMAL,
+            DoubleConsts.MIN_NORMAL,
+            1.0d,
+            3.0d,
+            Double_MAX_VALUEmm,
+            Double.MAX_VALUE
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            // isNaN
+            failures+=Tests.test("FpUtils.isNaN(double)", testCases[i],
+                                 FpUtils.isNaN(testCases[i]), (i ==0));
+
+            // isFinite
+            failures+=Tests.test("FpUtils.isFinite(double)", testCases[i],
+                                 FpUtils.isFinite(testCases[i]), (i >= 3));
+
+            // isInfinite
+            failures+=Tests.test("FpUtils.isInfinite(double)", testCases[i],
+                                 FpUtils.isInfinite(testCases[i]), (i==1 || i==2));
+
+            // isUnorderd
+            for(int j = 0; j < testCases.length; j++) {
+                failures+=Tests.test("FpUtils.isUnordered(double, double)", testCases[i],testCases[j],
+                                     FpUtils.isUnordered(testCases[i],testCases[j]), (i==0 || j==0));
+            }
+        }
+
+        return failures;
+    }
+
+    /* ******************** copySign tests******************************** */
+
+   public static int testFloatCopySign() {
+        int failures = 0;
+
+        // testCases[0] are logically positive numbers;
+        // testCases[1] are negative numbers.
+        float testCases [][] = {
+            {+0.0f,
+             Float.MIN_VALUE,
+             Float_MAX_SUBNORMALmm,
+             Float_MAX_SUBNORMAL,
+             FloatConsts.MIN_NORMAL,
+             1.0f,
+             3.0f,
+             Float_MAX_VALUEmm,
+             Float.MAX_VALUE,
+             infinityF,
+            },
+            {-infinityF,
+             -Float.MAX_VALUE,
+             -3.0f,
+             -1.0f,
+             -FloatConsts.MIN_NORMAL,
+             -Float_MAX_SUBNORMALmm,
+             -Float_MAX_SUBNORMAL,
+             -Float.MIN_VALUE,
+             -0.0f}
+        };
+
+        float NaNs[] = {Float.intBitsToFloat(0x7fc00000),       // "positive" NaN
+                        Float.intBitsToFloat(0xFfc00000)};      // "negative" NaN
+
+        // Tests shared between raw and non-raw versions
+        for(int i = 0; i < 2; i++) {
+            for(int j = 0; j < 2; j++) {
+                for(int m = 0; m < testCases[i].length; m++) {
+                    for(int n = 0; n < testCases[j].length; n++) {
+                        // copySign(magnitude, sign)
+                        failures+=Tests.test("Math.copySign(float,float)",
+                                             testCases[i][m],testCases[j][n],
+                                             Math.copySign(testCases[i][m], testCases[j][n]),
+                                             (j==0?1.0f:-1.0f)*Math.abs(testCases[i][m]) );
+
+                        failures+=Tests.test("StrictMath.copySign(float,float)",
+                                             testCases[i][m],testCases[j][n],
+                                             StrictMath.copySign(testCases[i][m], testCases[j][n]),
+                                             (j==0?1.0f:-1.0f)*Math.abs(testCases[i][m]) );
+                    }
+                }
+            }
+        }
+
+        // For rawCopySign, NaN may effectively have either sign bit
+        // while for copySign NaNs are treated as if they always have
+        // a zero sign bit (i.e. as positive numbers)
+        for(int i = 0; i < 2; i++) {
+            for(int j = 0; j < NaNs.length; j++) {
+                for(int m = 0; m < testCases[i].length; m++) {
+                    // copySign(magnitude, sign)
+
+                    failures += (Math.abs(Math.copySign(testCases[i][m], NaNs[j])) ==
+                                 Math.abs(testCases[i][m])) ? 0:1;
+
+
+                    failures+=Tests.test("StrictMath.copySign(float,float)",
+                                         testCases[i][m], NaNs[j],
+                                         StrictMath.copySign(testCases[i][m], NaNs[j]),
+                                         Math.abs(testCases[i][m]) );
+                }
+            }
+        }
+
+        return failures;
+    }
+
+    public static int testDoubleCopySign() {
+        int failures = 0;
+
+        // testCases[0] are logically positive numbers;
+        // testCases[1] are negative numbers.
+        double testCases [][] = {
+            {+0.0d,
+             Double.MIN_VALUE,
+             Double_MAX_SUBNORMALmm,
+             Double_MAX_SUBNORMAL,
+             DoubleConsts.MIN_NORMAL,
+             1.0d,
+             3.0d,
+             Double_MAX_VALUEmm,
+             Double.MAX_VALUE,
+             infinityD,
+            },
+            {-infinityD,
+             -Double.MAX_VALUE,
+             -3.0d,
+             -1.0d,
+             -DoubleConsts.MIN_NORMAL,
+             -Double_MAX_SUBNORMALmm,
+             -Double_MAX_SUBNORMAL,
+             -Double.MIN_VALUE,
+             -0.0d}
+        };
+
+        double NaNs[] = {Double.longBitsToDouble(0x7ff8000000000000L),  // "positive" NaN
+                         Double.longBitsToDouble(0xfff8000000000000L),  // "negative" NaN
+                         Double.longBitsToDouble(0x7FF0000000000001L),
+                         Double.longBitsToDouble(0xFFF0000000000001L),
+                         Double.longBitsToDouble(0x7FF8555555555555L),
+                         Double.longBitsToDouble(0xFFF8555555555555L),
+                         Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL),
+                         Double.longBitsToDouble(0xFFFFFFFFFFFFFFFFL),
+                         Double.longBitsToDouble(0x7FFDeadBeef00000L),
+                         Double.longBitsToDouble(0xFFFDeadBeef00000L),
+                         Double.longBitsToDouble(0x7FFCafeBabe00000L),
+                         Double.longBitsToDouble(0xFFFCafeBabe00000L)};
+
+        // Tests shared between Math and StrictMath versions
+        for(int i = 0; i < 2; i++) {
+            for(int j = 0; j < 2; j++) {
+                for(int m = 0; m < testCases[i].length; m++) {
+                    for(int n = 0; n < testCases[j].length; n++) {
+                        // copySign(magnitude, sign)
+                        failures+=Tests.test("MathcopySign(double,double)",
+                                             testCases[i][m],testCases[j][n],
+                                             Math.copySign(testCases[i][m], testCases[j][n]),
+                                             (j==0?1.0f:-1.0f)*Math.abs(testCases[i][m]) );
+
+                        failures+=Tests.test("StrictMath.copySign(double,double)",
+                                             testCases[i][m],testCases[j][n],
+                                             StrictMath.copySign(testCases[i][m], testCases[j][n]),
+                                             (j==0?1.0f:-1.0f)*Math.abs(testCases[i][m]) );
+                    }
+                }
+            }
+        }
+
+        // For Math.copySign, NaN may effectively have either sign bit
+        // while for StrictMath.copySign NaNs are treated as if they
+        // always have a zero sign bit (i.e. as positive numbers)
+        for(int i = 0; i < 2; i++) {
+            for(int j = 0; j < NaNs.length; j++) {
+                for(int m = 0; m < testCases[i].length; m++) {
+                    // copySign(magnitude, sign)
+
+                    failures += (Math.abs(Math.copySign(testCases[i][m], NaNs[j])) ==
+                                 Math.abs(testCases[i][m])) ? 0:1;
+
+
+                    failures+=Tests.test("StrictMath.copySign(double,double)",
+                                         testCases[i][m], NaNs[j],
+                                         StrictMath.copySign(testCases[i][m], NaNs[j]),
+                                         Math.abs(testCases[i][m]) );
+                }
+            }
+        }
+
+
+        return failures;
+    }
+
+    /* ************************ scalb tests ******************************* */
+
+    static int testScalbCase(float value, int scale_factor, float expected) {
+        int failures=0;
+
+        failures+=Tests.test("Math.scalb(float,int)",
+                             value, scale_factor,
+                             Math.scalb(value, scale_factor), expected);
+
+        failures+=Tests.test("Math.scalb(float,int)",
+                             -value, scale_factor,
+                             Math.scalb(-value, scale_factor), -expected);
+
+        failures+=Tests.test("StrictMath.scalb(float,int)",
+                             value, scale_factor,
+                             StrictMath.scalb(value, scale_factor), expected);
+
+        failures+=Tests.test("StrictMath.scalb(float,int)",
+                             -value, scale_factor,
+                             StrictMath.scalb(-value, scale_factor), -expected);
+        return failures;
+    }
+
+    public static int testFloatScalb() {
+        int failures=0;
+        int MAX_SCALE = FloatConsts.MAX_EXPONENT + -FloatConsts.MIN_EXPONENT +
+                        FloatConsts.SIGNIFICAND_WIDTH + 1;
+
+
+        // Arguments x, where scalb(x,n) is x for any n.
+        float [] identityTestCases = {NaNf,
+                                      -0.0f,
+                                      +0.0f,
+                                      infinityF,
+                                      -infinityF
+        };
+
+        float [] subnormalTestCases = {
+            Float.MIN_VALUE,
+            3.0f*Float.MIN_VALUE,
+            Float_MAX_SUBNORMALmm,
+            Float_MAX_SUBNORMAL
+        };
+
+        float [] someTestCases = {
+            Float.MIN_VALUE,
+            3.0f*Float.MIN_VALUE,
+            Float_MAX_SUBNORMALmm,
+            Float_MAX_SUBNORMAL,
+            FloatConsts.MIN_NORMAL,
+            1.0f,
+            2.0f,
+            3.0f,
+            (float)Math.PI,
+            Float_MAX_VALUEmm,
+            Float.MAX_VALUE
+        };
+
+        int [] oneMultiplyScalingFactors = {
+            FloatConsts.MIN_EXPONENT,
+            FloatConsts.MIN_EXPONENT+1,
+            -3,
+            -2,
+            -1,
+            0,
+            1,
+            2,
+            3,
+            FloatConsts.MAX_EXPONENT-1,
+            FloatConsts.MAX_EXPONENT
+        };
+
+        int [] manyScalingFactors = {
+            Integer.MIN_VALUE,
+            Integer.MIN_VALUE+1,
+            -MAX_SCALE -1,
+            -MAX_SCALE,
+            -MAX_SCALE+1,
+
+            2*FloatConsts.MIN_EXPONENT-1,       // -253
+            2*FloatConsts.MIN_EXPONENT,         // -252
+            2*FloatConsts.MIN_EXPONENT+1,       // -251
+
+            FpUtils.ilogb(Float.MIN_VALUE)-1,   // -150
+            FpUtils.ilogb(Float.MIN_VALUE),     // -149
+            -FloatConsts.MAX_EXPONENT,          // -127
+            FloatConsts.MIN_EXPONENT,           // -126
+
+            -2,
+            -1,
+            0,
+            1,
+            2,
+
+            FloatConsts.MAX_EXPONENT-1,         // 126
+            FloatConsts.MAX_EXPONENT,           // 127
+            FloatConsts.MAX_EXPONENT+1,         // 128
+
+            2*FloatConsts.MAX_EXPONENT-1,       // 253
+            2*FloatConsts.MAX_EXPONENT,         // 254
+            2*FloatConsts.MAX_EXPONENT+1,       // 255
+
+            MAX_SCALE-1,
+            MAX_SCALE,
+            MAX_SCALE+1,
+            Integer.MAX_VALUE-1,
+            Integer.MAX_VALUE
+        };
+
+        // Test cases where scaling is always a no-op
+        for(int i=0; i < identityTestCases.length; i++) {
+            for(int j=0; j < manyScalingFactors.length; j++) {
+                failures += testScalbCase(identityTestCases[i],
+                                          manyScalingFactors[j],
+                                          identityTestCases[i]);
+            }
+        }
+
+        // Test cases where result is 0.0 or infinity due to magnitude
+        // of the scaling factor
+        for(int i=0; i < someTestCases.length; i++) {
+            for(int j=0; j < manyScalingFactors.length; j++) {
+                int scaleFactor = manyScalingFactors[j];
+                if (Math.abs(scaleFactor) >= MAX_SCALE) {
+                    float value = someTestCases[i];
+                    failures+=testScalbCase(value,
+                                            scaleFactor,
+                                            FpUtils.copySign( (scaleFactor>0?infinityF:0.0f), value) );
+                }
+            }
+        }
+
+        // Test cases that could be done with one floating-point
+        // multiply.
+        for(int i=0; i < someTestCases.length; i++) {
+            for(int j=0; j < oneMultiplyScalingFactors.length; j++) {
+                int scaleFactor = oneMultiplyScalingFactors[j];
+                    float value = someTestCases[i];
+
+                    failures+=testScalbCase(value,
+                                            scaleFactor,
+                                            value*powerOfTwoF(scaleFactor));
+            }
+        }
+
+        // Create 2^MAX_EXPONENT
+        float twoToTheMaxExp = 1.0f; // 2^0
+        for(int i = 0; i < FloatConsts.MAX_EXPONENT; i++)
+            twoToTheMaxExp *=2.0f;
+
+        // Scale-up subnormal values until they all overflow
+        for(int i=0; i < subnormalTestCases.length; i++) {
+            float scale = 1.0f; // 2^j
+            float value = subnormalTestCases[i];
+
+            for(int j=FloatConsts.MAX_EXPONENT*2; j < MAX_SCALE; j++) { // MAX_SCALE -1 should cause overflow
+                int scaleFactor = j;
+
+                failures+=testScalbCase(value,
+                                        scaleFactor,
+                                        (FpUtils.ilogb(value) +j > FloatConsts.MAX_EXPONENT ) ?
+                                        FpUtils.copySign(infinityF, value) : // overflow
+                                        // calculate right answer
+                                        twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
+                scale*=2.0f;
+            }
+        }
+
+        // Scale down a large number until it underflows.  By scaling
+        // down MAX_NORMALmm, the first subnormal result will be exact
+        // but the next one will round -- all those results can be
+        // checked by halving a separate value in the loop.  Actually,
+        // we can keep halving and checking until the product is zero
+        // since:
+        //
+        // 1. If the scalb of MAX_VALUEmm is subnormal and *not* exact
+        // it will round *up*
+        //
+        // 2. When rounding first occurs in the expected product, it
+        // too rounds up, to 2^-MAX_EXPONENT.
+        //
+        // Halving expected after rounding happends to give the same
+        // result as the scalb operation.
+        float expected = Float_MAX_VALUEmm *0.5f;
+        for(int i = -1; i > -MAX_SCALE; i--) {
+            failures+=testScalbCase(Float_MAX_VALUEmm, i, expected);
+
+            expected *= 0.5f;
+        }
+
+        // Tricky rounding tests:
+        // Scale down a large number into subnormal range such that if
+        // scalb is being implemented with multiple floating-point
+        // multiplies, the value would round twice if the multiplies
+        // were done in the wrong order.
+
+        float value = 0x8.0000bP-5f;
+        expected = 0x1.00001p-129f;
+
+        for(int i = 0; i < 129; i++) {
+            failures+=testScalbCase(value,
+                                    -127-i,
+                                    expected);
+            value *=2.0f;
+        }
+
+        return failures;
+    }
+
+    static int testScalbCase(double value, int scale_factor, double expected) {
+        int failures=0;
+
+        failures+=Tests.test("Math.scalb(double,int)",
+                             value, scale_factor,
+                             Math.scalb(value, scale_factor), expected);
+
+        failures+=Tests.test("Math.scalb(double,int)",
+                             -value, scale_factor,
+                             Math.scalb(-value, scale_factor), -expected);
+
+        failures+=Tests.test("StrictMath.scalb(double,int)",
+                             value, scale_factor,
+                             StrictMath.scalb(value, scale_factor), expected);
+
+        failures+=Tests.test("StrictMath.scalb(double,int)",
+                             -value, scale_factor,
+                             StrictMath.scalb(-value, scale_factor), -expected);
+
+        return failures;
+    }
+
+    public static int testDoubleScalb() {
+        int failures=0;
+        int MAX_SCALE = DoubleConsts.MAX_EXPONENT + -DoubleConsts.MIN_EXPONENT +
+                        DoubleConsts.SIGNIFICAND_WIDTH + 1;
+
+
+        // Arguments x, where scalb(x,n) is x for any n.
+        double [] identityTestCases = {NaNd,
+                                      -0.0,
+                                      +0.0,
+                                      infinityD,
+        };
+
+        double [] subnormalTestCases = {
+            Double.MIN_VALUE,
+            3.0d*Double.MIN_VALUE,
+            Double_MAX_SUBNORMALmm,
+            Double_MAX_SUBNORMAL
+        };
+
+        double [] someTestCases = {
+            Double.MIN_VALUE,
+            3.0d*Double.MIN_VALUE,
+            Double_MAX_SUBNORMALmm,
+            Double_MAX_SUBNORMAL,
+            DoubleConsts.MIN_NORMAL,
+            1.0d,
+            2.0d,
+            3.0d,
+            Math.PI,
+            Double_MAX_VALUEmm,
+            Double.MAX_VALUE
+        };
+
+        int [] oneMultiplyScalingFactors = {
+            DoubleConsts.MIN_EXPONENT,
+            DoubleConsts.MIN_EXPONENT+1,
+            -3,
+            -2,
+            -1,
+            0,
+            1,
+            2,
+            3,
+            DoubleConsts.MAX_EXPONENT-1,
+            DoubleConsts.MAX_EXPONENT
+        };
+
+        int [] manyScalingFactors = {
+            Integer.MIN_VALUE,
+            Integer.MIN_VALUE+1,
+            -MAX_SCALE -1,
+            -MAX_SCALE,
+            -MAX_SCALE+1,
+
+            2*DoubleConsts.MIN_EXPONENT-1,      // -2045
+            2*DoubleConsts.MIN_EXPONENT,        // -2044
+            2*DoubleConsts.MIN_EXPONENT+1,      // -2043
+
+            FpUtils.ilogb(Double.MIN_VALUE)-1,  // -1076
+            FpUtils.ilogb(Double.MIN_VALUE),    // -1075
+            -DoubleConsts.MAX_EXPONENT,         // -1023
+            DoubleConsts.MIN_EXPONENT,          // -1022
+
+            -2,
+            -1,
+            0,
+            1,
+            2,
+
+            DoubleConsts.MAX_EXPONENT-1,        // 1022
+            DoubleConsts.MAX_EXPONENT,          // 1023
+            DoubleConsts.MAX_EXPONENT+1,        // 1024
+
+            2*DoubleConsts.MAX_EXPONENT-1,      // 2045
+            2*DoubleConsts.MAX_EXPONENT,        // 2046
+            2*DoubleConsts.MAX_EXPONENT+1,      // 2047
+
+            MAX_SCALE-1,
+            MAX_SCALE,
+            MAX_SCALE+1,
+            Integer.MAX_VALUE-1,
+            Integer.MAX_VALUE
+        };
+
+        // Test cases where scaling is always a no-op
+        for(int i=0; i < identityTestCases.length; i++) {
+            for(int j=0; j < manyScalingFactors.length; j++) {
+                failures += testScalbCase(identityTestCases[i],
+                                          manyScalingFactors[j],
+                                          identityTestCases[i]);
+            }
+        }
+
+        // Test cases where result is 0.0 or infinity due to magnitude
+        // of the scaling factor
+        for(int i=0; i < someTestCases.length; i++) {
+            for(int j=0; j < manyScalingFactors.length; j++) {
+                int scaleFactor = manyScalingFactors[j];
+                if (Math.abs(scaleFactor) >= MAX_SCALE) {
+                    double value = someTestCases[i];
+                    failures+=testScalbCase(value,
+                                            scaleFactor,
+                                            FpUtils.copySign( (scaleFactor>0?infinityD:0.0), value) );
+                }
+            }
+        }
+
+        // Test cases that could be done with one floating-point
+        // multiply.
+        for(int i=0; i < someTestCases.length; i++) {
+            for(int j=0; j < oneMultiplyScalingFactors.length; j++) {
+                int scaleFactor = oneMultiplyScalingFactors[j];
+                    double value = someTestCases[i];
+
+                    failures+=testScalbCase(value,
+                                            scaleFactor,
+                                            value*powerOfTwoD(scaleFactor));
+            }
+        }
+
+        // Create 2^MAX_EXPONENT
+        double twoToTheMaxExp = 1.0; // 2^0
+        for(int i = 0; i < DoubleConsts.MAX_EXPONENT; i++)
+            twoToTheMaxExp *=2.0;
+
+        // Scale-up subnormal values until they all overflow
+        for(int i=0; i < subnormalTestCases.length; i++) {
+            double scale = 1.0; // 2^j
+            double value = subnormalTestCases[i];
+
+            for(int j=DoubleConsts.MAX_EXPONENT*2; j < MAX_SCALE; j++) { // MAX_SCALE -1 should cause overflow
+                int scaleFactor = j;
+
+                failures+=testScalbCase(value,
+                                        scaleFactor,
+                                        (FpUtils.ilogb(value) +j > DoubleConsts.MAX_EXPONENT ) ?
+                                        FpUtils.copySign(infinityD, value) : // overflow
+                                        // calculate right answer
+                                        twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
+                scale*=2.0;
+            }
+        }
+
+        // Scale down a large number until it underflows.  By scaling
+        // down MAX_NORMALmm, the first subnormal result will be exact
+        // but the next one will round -- all those results can be
+        // checked by halving a separate value in the loop.  Actually,
+        // we can keep halving and checking until the product is zero
+        // since:
+        //
+        // 1. If the scalb of MAX_VALUEmm is subnormal and *not* exact
+        // it will round *up*
+        //
+        // 2. When rounding first occurs in the expected product, it
+        // too rounds up, to 2^-MAX_EXPONENT.
+        //
+        // Halving expected after rounding happends to give the same
+        // result as the scalb operation.
+        double expected = Double_MAX_VALUEmm *0.5f;
+        for(int i = -1; i > -MAX_SCALE; i--) {
+            failures+=testScalbCase(Double_MAX_VALUEmm, i, expected);
+
+            expected *= 0.5;
+        }
+
+        // Tricky rounding tests:
+        // Scale down a large number into subnormal range such that if
+        // scalb is being implemented with multiple floating-point
+        // multiplies, the value would round twice if the multiplies
+        // were done in the wrong order.
+
+        double value = 0x1.000000000000bP-1;
+        expected     = 0x0.2000000000001P-1022;
+        for(int i = 0; i < DoubleConsts.MAX_EXPONENT+2; i++) {
+            failures+=testScalbCase(value,
+                                    -1024-i,
+                                    expected);
+            value *=2.0;
+        }
+
+        return failures;
+    }
+
+    /* ************************* ulp tests ******************************* */
+
+
+    /*
+     * Test Math.ulp and StrictMath.ulp with +d and -d.
+     */
+    static int testUlpCase(float f, float expected) {
+        float minus_f = -f;
+        int failures=0;
+
+        failures+=Tests.test("Math.ulp(float)", f,
+                             Math.ulp(f), expected);
+        failures+=Tests.test("Math.ulp(float)", minus_f,
+                             Math.ulp(minus_f), expected);
+        failures+=Tests.test("StrictMath.ulp(float)", f,
+                             StrictMath.ulp(f), expected);
+        failures+=Tests.test("StrictMath.ulp(float)", minus_f,
+                             StrictMath.ulp(minus_f), expected);
+        return failures;
+    }
+
+    static int testUlpCase(double d, double expected) {
+        double minus_d = -d;
+        int failures=0;
+
+        failures+=Tests.test("Math.ulp(double)", d,
+                             Math.ulp(d), expected);
+        failures+=Tests.test("Math.ulp(double)", minus_d,
+                             Math.ulp(minus_d), expected);
+        failures+=Tests.test("StrictMath.ulp(double)", d,
+                             StrictMath.ulp(d), expected);
+        failures+=Tests.test("StrictMath.ulp(double)", minus_d,
+                             StrictMath.ulp(minus_d), expected);
+        return failures;
+    }
+
+    public static int testFloatUlp() {
+        int failures = 0;
+        float [] specialValues = {NaNf,
+                                  Float.POSITIVE_INFINITY,
+                                  +0.0f,
+                                  +1.0f,
+                                  +2.0f,
+                                  +16.0f,
+                                  +Float.MIN_VALUE,
+                                  +Float_MAX_SUBNORMAL,
+                                  +FloatConsts.MIN_NORMAL,
+                                  +Float.MAX_VALUE
+        };
+
+        float [] specialResults = {NaNf,
+                                   Float.POSITIVE_INFINITY,
+                                   Float.MIN_VALUE,
+                                   powerOfTwoF(-23),
+                                   powerOfTwoF(-22),
+                                   powerOfTwoF(-19),
+                                   Float.MIN_VALUE,
+                                   Float.MIN_VALUE,
+                                   Float.MIN_VALUE,
+                                   powerOfTwoF(104)
+        };
+
+        // Special value tests
+        for(int i = 0; i < specialValues.length; i++) {
+            failures += testUlpCase(specialValues[i], specialResults[i]);
+        }
+
+
+        // Normal exponent tests
+        for(int i = FloatConsts.MIN_EXPONENT; i <= FloatConsts.MAX_EXPONENT; i++) {
+            float expected;
+
+            // Create power of two
+            float po2 = powerOfTwoF(i);
+            expected = FpUtils.scalb(1.0f, i - (FloatConsts.SIGNIFICAND_WIDTH-1));
+
+            failures += testUlpCase(po2, expected);
+
+            // Generate some random bit patterns for the significand
+            for(int j = 0; j < 10; j++) {
+                int randSignif = rand.nextInt();
+                float randFloat;
+
+                randFloat = Float.intBitsToFloat( // Exponent
+                                                 (Float.floatToIntBits(po2)&
+                                                  (~FloatConsts.SIGNIF_BIT_MASK)) |
+                                                 // Significand
+                                                 (randSignif &
+                                                  FloatConsts.SIGNIF_BIT_MASK) );
+
+                failures += testUlpCase(randFloat, expected);
+            }
+
+            if (i > FloatConsts.MIN_EXPONENT) {
+                float po2minus = FpUtils.nextAfter(po2,
+                                                   Float.NEGATIVE_INFINITY);
+                failures += testUlpCase(po2minus, expected/2.0f);
+            }
+        }
+
+        // Subnormal tests
+
+        /*
+         * Start with MIN_VALUE, left shift, test high value, low
+         * values, and random in between.
+         *
+         * Use nextAfter to calculate, high value of previous binade,
+         * loop count i will indicate how many random bits, if any are
+         * needed.
+         */
+
+        float top=Float.MIN_VALUE;
+        for( int i = 1;
+            i < FloatConsts.SIGNIFICAND_WIDTH;
+            i++, top *= 2.0f) {
+
+            failures += testUlpCase(top, Float.MIN_VALUE);
+
+            // Test largest value in next smaller binade
+            if (i >= 3) {// (i == 1) would test 0.0;
+                         // (i == 2) would just retest MIN_VALUE
+                testUlpCase(FpUtils.nextAfter(top, 0.0f),
+                            Float.MIN_VALUE);
+
+                if( i >= 10) {
+                    // create a bit mask with (i-1) 1's in the low order
+                    // bits
+                    int mask = ~((~0)<<(i-1));
+                    float randFloat = Float.intBitsToFloat( // Exponent
+                                                 Float.floatToIntBits(top) |
+                                                 // Significand
+                                                 (rand.nextInt() & mask ) ) ;
+
+                    failures += testUlpCase(randFloat, Float.MIN_VALUE);
+                }
+            }
+        }
+
+        return failures;
+    }
+
+    public static int testDoubleUlp() {
+        int failures = 0;
+        double [] specialValues = {NaNd,
+                                  Double.POSITIVE_INFINITY,
+                                  +0.0d,
+                                  +1.0d,
+                                  +2.0d,
+                                  +16.0d,
+                                  +Double.MIN_VALUE,
+                                  +Double_MAX_SUBNORMAL,
+                                  +DoubleConsts.MIN_NORMAL,
+                                  +Double.MAX_VALUE
+        };
+
+        double [] specialResults = {NaNf,
+                                   Double.POSITIVE_INFINITY,
+                                   Double.MIN_VALUE,
+                                   powerOfTwoD(-52),
+                                   powerOfTwoD(-51),
+                                   powerOfTwoD(-48),
+                                   Double.MIN_VALUE,
+                                   Double.MIN_VALUE,
+                                   Double.MIN_VALUE,
+                                   powerOfTwoD(971)
+        };
+
+        // Special value tests
+        for(int i = 0; i < specialValues.length; i++) {
+            failures += testUlpCase(specialValues[i], specialResults[i]);
+        }
+
+
+        // Normal exponent tests
+        for(int i = DoubleConsts.MIN_EXPONENT; i <= DoubleConsts.MAX_EXPONENT; i++) {
+            double expected;
+
+            // Create power of two
+            double po2 = powerOfTwoD(i);
+            expected = FpUtils.scalb(1.0, i - (DoubleConsts.SIGNIFICAND_WIDTH-1));
+
+            failures += testUlpCase(po2, expected);
+
+            // Generate some random bit patterns for the significand
+            for(int j = 0; j < 10; j++) {
+                long randSignif = rand.nextLong();
+                double randDouble;
+
+                randDouble = Double.longBitsToDouble( // Exponent
+                                                 (Double.doubleToLongBits(po2)&
+                                                  (~DoubleConsts.SIGNIF_BIT_MASK)) |
+                                                 // Significand
+                                                 (randSignif &
+                                                  DoubleConsts.SIGNIF_BIT_MASK) );
+
+                failures += testUlpCase(randDouble, expected);
+            }
+
+            if (i > DoubleConsts.MIN_EXPONENT) {
+                double po2minus = FpUtils.nextAfter(po2,
+                                                    Double.NEGATIVE_INFINITY);
+                failures += testUlpCase(po2minus, expected/2.0f);
+            }
+        }
+
+        // Subnormal tests
+
+        /*
+         * Start with MIN_VALUE, left shift, test high value, low
+         * values, and random in between.
+         *
+         * Use nextAfter to calculate, high value of previous binade,
+         * loop count i will indicate how many random bits, if any are
+         * needed.
+         */
+
+        double top=Double.MIN_VALUE;
+        for( int i = 1;
+            i < DoubleConsts.SIGNIFICAND_WIDTH;
+            i++, top *= 2.0f) {
+
+            failures += testUlpCase(top, Double.MIN_VALUE);
+
+            // Test largest value in next smaller binade
+            if (i >= 3) {// (i == 1) would test 0.0;
+                         // (i == 2) would just retest MIN_VALUE
+                testUlpCase(FpUtils.nextAfter(top, 0.0f),
+                            Double.MIN_VALUE);
+
+                if( i >= 10) {
+                    // create a bit mask with (i-1) 1's in the low order
+                    // bits
+                    int mask = ~((~0)<<(i-1));
+                    double randDouble = Double.longBitsToDouble( // Exponent
+                                                 Double.doubleToLongBits(top) |
+                                                 // Significand
+                                                 (rand.nextLong() & mask ) ) ;
+
+                    failures += testUlpCase(randDouble, Double.MIN_VALUE);
+                }
+            }
+        }
+
+        return failures;
+    }
+
+    public static int testFloatSignum() {
+        int failures = 0;
+        float testCases [][] = {
+            {NaNf,                      NaNf},
+            {-infinityF,                -1.0f},
+            {-Float.MAX_VALUE,          -1.0f},
+            {-FloatConsts.MIN_NORMAL,   -1.0f},
+            {-1.0f,                     -1.0f},
+            {-2.0f,                     -1.0f},
+            {-Float_MAX_SUBNORMAL,      -1.0f},
+            {-Float.MIN_VALUE,          -1.0f},
+            {-0.0f,                     -0.0f},
+            {+0.0f,                     +0.0f},
+            {Float.MIN_VALUE,            1.0f},
+            {Float_MAX_SUBNORMALmm,      1.0f},
+            {Float_MAX_SUBNORMAL,        1.0f},
+            {FloatConsts.MIN_NORMAL,     1.0f},
+            {1.0f,                       1.0f},
+            {2.0f,                       1.0f},
+            {Float_MAX_VALUEmm,          1.0f},
+            {Float.MAX_VALUE,            1.0f},
+            {infinityF,                  1.0f}
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            failures+=Tests.test("Math.signum(float)",
+                                 testCases[i][0], Math.signum(testCases[i][0]), testCases[i][1]);
+            failures+=Tests.test("StrictMath.signum(float)",
+                                 testCases[i][0], StrictMath.signum(testCases[i][0]), testCases[i][1]);
+        }
+
+        return failures;
+    }
+
+    public static int testDoubleSignum() {
+        int failures = 0;
+        double testCases [][] = {
+            {NaNd,                      NaNd},
+            {-infinityD,                -1.0},
+            {-Double.MAX_VALUE,         -1.0},
+            {-DoubleConsts.MIN_NORMAL,  -1.0},
+            {-1.0,                      -1.0},
+            {-2.0,                      -1.0},
+            {-Double_MAX_SUBNORMAL,     -1.0},
+            {-Double.MIN_VALUE,         -1.0d},
+            {-0.0d,                     -0.0d},
+            {+0.0d,                     +0.0d},
+            {Double.MIN_VALUE,           1.0},
+            {Double_MAX_SUBNORMALmm,     1.0},
+            {Double_MAX_SUBNORMAL,       1.0},
+            {DoubleConsts.MIN_NORMAL,    1.0},
+            {1.0,                        1.0},
+            {2.0,                        1.0},
+            {Double_MAX_VALUEmm,         1.0},
+            {Double.MAX_VALUE,           1.0},
+            {infinityD,                  1.0}
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            failures+=Tests.test("Math.signum(double)",
+                                 testCases[i][0], Math.signum(testCases[i][0]), testCases[i][1]);
+            failures+=Tests.test("StrictMath.signum(double)",
+                                 testCases[i][0], StrictMath.signum(testCases[i][0]), testCases[i][1]);
+        }
+
+        return failures;
+    }
+
+
+    public static void main(String argv[]) {
+        int failures = 0;
+
+        failures += testFloatGetExponent();
+        failures += testDoubleGetExponent();
+
+        failures += testFloatNextAfter();
+        failures += testDoubleNextAfter();
+
+        failures += testFloatNextUp();
+        failures += testDoubleNextUp();
+
+        failures += testFloatNextDown();
+        failures += testDoubleNextDown();
+
+        failures += testFloatBooleanMethods();
+        failures += testDoubleBooleanMethods();
+
+        failures += testFloatCopySign();
+        failures += testDoubleCopySign();
+
+        failures += testFloatScalb();
+        failures += testDoubleScalb();
+
+        failures += testFloatUlp();
+        failures += testDoubleUlp();
+
+        failures += testFloatSignum();
+        failures += testDoubleSignum();
+
+        if (failures > 0) {
+            System.err.println("Testing the recommended functions incurred "
+                               + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Math/Log10Tests.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,223 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4074599 4939441
+ * @summary Tests for {Math, StrictMath}.log10
+ * @author Joseph D. Darcy
+ */
+
+import sun.misc.FpUtils;
+import sun.misc.DoubleConsts;
+
+public class Log10Tests {
+    private Log10Tests(){}
+
+    static final double infinityD = Double.POSITIVE_INFINITY;
+    static final double NaNd = Double.NaN;
+    static final double LN_10 = StrictMath.log(10.0);
+
+    // Initialize shared random number generator
+    static java.util.Random rand = new java.util.Random(0L);
+
+    static int testLog10Case(double input, double expected) {
+        int failures=0;
+
+        failures+=Tests.test("Math.log10(double)", input,
+                             Math.log10(input), expected);
+
+        failures+=Tests.test("StrictMath.log10(double)", input,
+                             StrictMath.log10(input), expected);
+
+        return failures;
+    }
+
+    static int testLog10() {
+        int failures = 0;
+
+        double [][] testCases = {
+            {Double.NaN,                NaNd},
+            {Double.longBitsToDouble(0x7FF0000000000001L),      NaNd},
+            {Double.longBitsToDouble(0xFFF0000000000001L),      NaNd},
+            {Double.longBitsToDouble(0x7FF8555555555555L),      NaNd},
+            {Double.longBitsToDouble(0xFFF8555555555555L),      NaNd},
+            {Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL),      NaNd},
+            {Double.longBitsToDouble(0xFFFFFFFFFFFFFFFFL),      NaNd},
+            {Double.longBitsToDouble(0x7FFDeadBeef00000L),      NaNd},
+            {Double.longBitsToDouble(0xFFFDeadBeef00000L),      NaNd},
+            {Double.longBitsToDouble(0x7FFCafeBabe00000L),      NaNd},
+            {Double.longBitsToDouble(0xFFFCafeBabe00000L),      NaNd},
+            {Double.NEGATIVE_INFINITY,  NaNd},
+            {-8.0,                      NaNd},
+            {-1.0,                      NaNd},
+            {-DoubleConsts.MIN_NORMAL,  NaNd},
+            {-Double.MIN_VALUE,         NaNd},
+            {-0.0,                      -infinityD},
+            {+0.0,                      -infinityD},
+            {+1.0,                      0.0},
+            {Double.POSITIVE_INFINITY,  infinityD},
+        };
+
+        // Test special cases
+        for(int i = 0; i < testCases.length; i++) {
+            failures += testLog10Case(testCases[i][0],
+                                          testCases[i][1]);
+        }
+
+        // Test log10(10^n) == n for integer n; 10^n, n < 0 is not
+        // exactly representable as a floating-point value -- up to
+        // 10^22 can be represented exactly
+        double testCase = 1.0;
+        for(int i = 0; i < 23; i++) {
+            failures += testLog10Case(testCase, i);
+            testCase *= 10.0;
+        }
+
+        // Test for gross inaccuracy by comparing to log; should be
+        // within a few ulps of log(x)/log(10)
+        for(int i = 0; i < 10000; i++) {
+            double input = Double.longBitsToDouble(rand.nextLong());
+            if(! FpUtils.isFinite(input))
+                continue; // avoid testing NaN and infinite values
+            else {
+                input = Math.abs(input);
+
+                double expected = StrictMath.log(input)/LN_10;
+                if( ! FpUtils.isFinite(expected))
+                    continue; // if log(input) overflowed, try again
+                else {
+                    double result;
+
+                    if( Math.abs(((result=Math.log10(input)) - expected)/Math.ulp(expected)) > 3) {
+                        failures++;
+                        System.err.println("For input " + input +
+                                           ", Math.log10 was more than 3 ulps different from " +
+                                           "log(input)/log(10): log10(input) = " + result +
+                                           "\tlog(input)/log(10) = " + expected);
+                    }
+
+                    if( Math.abs(((result=StrictMath.log10(input)) - expected)/Math.ulp(expected)) > 3) {
+                        failures++;
+                        System.err.println("For input " + input +
+                                           ", StrictMath.log10 was more than 3 ulps different from " +
+                                           "log(input)/log(10): log10(input) = " + result +
+                                           "\tlog(input)/log(10) = " + expected);
+                    }
+
+
+                }
+            }
+        }
+
+        // Test for accuracy and monotonicity near log10(1.0).  From
+        // the Taylor expansion of log,
+        // log10(1+z) ~= (z -(z^2)/2)/LN_10;
+        {
+            double neighbors[] =        new double[40];
+            double neighborsStrict[] =  new double[40];
+            double z = Double.NaN;
+
+            // Test inputs greater than 1.0.
+            neighbors[0] =              Math.log10(1.0);
+            neighborsStrict[0] =        StrictMath.log10(1.0);
+
+            double input[] =  new double[40];
+            int half = input.length/2;
+
+
+            // Initialize input to the 40 consecutive double values
+            // "centered" at 1.0.
+            double up = Double.NaN;
+            double down = Double.NaN;
+            for(int i = 0; i < half; i++) {
+                if (i == 0) {
+                    input[half] = 1.0;
+                    up   = FpUtils.nextUp(1.0);
+                    down = FpUtils.nextDown(1.0);
+                } else {
+                    input[half + i] = up;
+                    input[half - i] = down;
+                    up   = FpUtils.nextUp(up);
+                    down = FpUtils.nextDown(down);
+                }
+            }
+            input[0] = FpUtils.nextDown(input[1]);
+
+            for(int i = 0; i < neighbors.length; i++) {
+                neighbors[i] =          Math.log10(input[i]);
+                neighborsStrict[i] =    StrictMath.log10(input[i]);
+
+                // Test accuracy.
+                z = input[i] - 1.0;
+                double expected = (z - (z*z)*0.5)/LN_10;
+                if ( Math.abs(neighbors[i] - expected ) > 3*Math.ulp(expected) ) {
+                    failures++;
+                    System.err.println("For input near 1.0 " + input[i] +
+                                       ", Math.log10(1+z) was more than 3 ulps different from " +
+                                       "(z-(z^2)/2)/ln(10): log10(input) = " + neighbors[i] +
+                                       "\texpected about = " + expected);
+                }
+
+                if ( Math.abs(neighborsStrict[i] - expected ) > 3*Math.ulp(expected) ) {
+                    failures++;
+                    System.err.println("For input near 1.0 " + input[i] +
+                                       ", StrictMath.log10(1+z) was more than 3 ulps different from " +
+                                       "(z-(z^2)/2)/ln(10): log10(input) = " + neighborsStrict[i] +
+                                       "\texpected about = " + expected);
+                }
+
+                // Test monotonicity
+                if( i > 0) {
+                    if( neighbors[i-1] > neighbors[i] ) {
+                        failures++;
+                        System.err.println("Monotonicity failure for Math.log10  at " + input[i] +
+                                           " and prior value.");
+                    }
+
+                    if( neighborsStrict[i-1] > neighborsStrict[i] ) {
+                        failures++;
+                        System.err.println("Monotonicity failure for StrictMath.log10  at " + input[i] +
+                                           " and prior value.");
+                    }
+                }
+            }
+
+        }
+
+        return failures;
+    }
+
+    public static void main(String argv[]) {
+        int failures = 0;
+
+        failures += testLog10();
+
+        if (failures > 0) {
+            System.err.println("Testing log10 incurred "
+                               + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Math/Log1pTests.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4851638 4939441
+ * @summary Tests for {Math, StrictMath}.log1p
+ * @author Joseph D. Darcy
+ */
+
+import sun.misc.DoubleConsts;
+import sun.misc.FpUtils;
+
+public class Log1pTests {
+    private Log1pTests(){}
+
+    static final double infinityD = Double.POSITIVE_INFINITY;
+    static final double NaNd = Double.NaN;
+
+    /**
+     * Formulation taken from HP-15C Advanced Functions Handbook, part
+     * number HP 0015-90011, p 181.  This is accurate to a few ulps.
+     */
+    static double hp15cLogp(double x) {
+        double u = 1.0 + x;
+        return (u==1.0? x : StrictMath.log(u)*x/(u-1) );
+    }
+
+    /*
+     * The Taylor expansion of ln(1 + x) for -1 < x <= 1 is:
+     *
+     * x - x^2/2 + x^3/3 - ... -(-x^j)/j
+     *
+     * Therefore, for small values of x, log1p(x) ~= x.  For large
+     * values of x, log1p(x) ~= log(x).
+     *
+     * Also x/(x+1) < ln(1+x) < x
+     */
+
+    static int testLog1p() {
+        int failures = 0;
+
+        double [][] testCases = {
+            {Double.NaN,                NaNd},
+            {Double.longBitsToDouble(0x7FF0000000000001L),      NaNd},
+            {Double.longBitsToDouble(0xFFF0000000000001L),      NaNd},
+            {Double.longBitsToDouble(0x7FF8555555555555L),      NaNd},
+            {Double.longBitsToDouble(0xFFF8555555555555L),      NaNd},
+            {Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL),      NaNd},
+            {Double.longBitsToDouble(0xFFFFFFFFFFFFFFFFL),      NaNd},
+            {Double.longBitsToDouble(0x7FFDeadBeef00000L),      NaNd},
+            {Double.longBitsToDouble(0xFFFDeadBeef00000L),      NaNd},
+            {Double.longBitsToDouble(0x7FFCafeBabe00000L),      NaNd},
+            {Double.longBitsToDouble(0xFFFCafeBabe00000L),      NaNd},
+            {Double.NEGATIVE_INFINITY,  NaNd},
+            {-8.0,                      NaNd},
+            {-1.0,                      -infinityD},
+            {-0.0,                      -0.0},
+            {+0.0,                      +0.0},
+            {infinityD,                 infinityD},
+        };
+
+        // Test special cases
+        for(int i = 0; i < testCases.length; i++) {
+            failures += testLog1pCaseWithUlpDiff(testCases[i][0],
+                                                 testCases[i][1], 0);
+        }
+
+        // For |x| < 2^-54 log1p(x) ~= x
+        for(int i = DoubleConsts.MIN_SUB_EXPONENT; i <= -54; i++) {
+            double d = FpUtils.scalb(2, i);
+            failures += testLog1pCase(d, d);
+            failures += testLog1pCase(-d, -d);
+        }
+
+        // For x > 2^53 log1p(x) ~= log(x)
+        for(int i = 53; i <= DoubleConsts.MAX_EXPONENT; i++) {
+            double d = FpUtils.scalb(2, i);
+            failures += testLog1pCaseWithUlpDiff(d, StrictMath.log(d), 2.001);
+        }
+
+        // Construct random values with exponents ranging from -53 to
+        // 52 and compare against HP-15C formula.
+        java.util.Random rand = new java.util.Random();
+        for(int i = 0; i < 1000; i++) {
+            double d = rand.nextDouble();
+
+            d = FpUtils.scalb(d, -53 - FpUtils.ilogb(d));
+
+            for(int j = -53; j <= 52; j++) {
+                failures += testLog1pCaseWithUlpDiff(d, hp15cLogp(d), 5);
+
+                d *= 2.0; // increase exponent by 1
+            }
+        }
+
+        // Test for monotonicity failures near values y-1 where y ~=
+        // e^x.  Test two numbers before and two numbers after each
+        // chosen value; i.e.
+        //
+        // pcNeighbors[] =
+        // {nextDown(nextDown(pc)),
+        // nextDown(pc),
+        // pc,
+        // nextUp(pc),
+        // nextUp(nextUp(pc))}
+        //
+        // and we test that log1p(pcNeighbors[i]) <= log1p(pcNeighbors[i+1])
+        {
+            double pcNeighbors[] = new double[5];
+            double pcNeighborsLog1p[] = new double[5];
+            double pcNeighborsStrictLog1p[] = new double[5];
+
+            for(int i = -36; i <= 36; i++) {
+                double pc = StrictMath.pow(Math.E, i) - 1;
+
+                pcNeighbors[2] = pc;
+                pcNeighbors[1] = FpUtils.nextDown(pc);
+                pcNeighbors[0] = FpUtils.nextDown(pcNeighbors[1]);
+                pcNeighbors[3] = FpUtils.nextUp(pc);
+                pcNeighbors[4] = FpUtils.nextUp(pcNeighbors[3]);
+
+                for(int j = 0; j < pcNeighbors.length; j++) {
+                    pcNeighborsLog1p[j]       =       Math.log1p(pcNeighbors[j]);
+                    pcNeighborsStrictLog1p[j] = StrictMath.log1p(pcNeighbors[j]);
+                }
+
+                for(int j = 0; j < pcNeighborsLog1p.length-1; j++) {
+                    if(pcNeighborsLog1p[j] >  pcNeighborsLog1p[j+1] ) {
+                        failures++;
+                        System.err.println("Monotonicity failure for Math.log1p on " +
+                                          pcNeighbors[j] + " and "  +
+                                          pcNeighbors[j+1] + "\n\treturned " +
+                                          pcNeighborsLog1p[j] + " and " +
+                                          pcNeighborsLog1p[j+1] );
+                    }
+
+                    if(pcNeighborsStrictLog1p[j] >  pcNeighborsStrictLog1p[j+1] ) {
+                        failures++;
+                        System.err.println("Monotonicity failure for StrictMath.log1p on " +
+                                          pcNeighbors[j] + " and "  +
+                                          pcNeighbors[j+1] + "\n\treturned " +
+                                          pcNeighborsStrictLog1p[j] + " and " +
+                                          pcNeighborsStrictLog1p[j+1] );
+                    }
+
+
+                }
+
+            }
+        }
+
+        return failures;
+    }
+
+    public static int testLog1pCase(double input,
+                                    double expected) {
+        return testLog1pCaseWithUlpDiff(input, expected, 1);
+    }
+
+    public static int testLog1pCaseWithUlpDiff(double input,
+                                               double expected,
+                                               double ulps) {
+        int failures = 0;
+        failures += Tests.testUlpDiff("Math.lop1p(double",
+                                      input, Math.log1p(input),
+                                      expected, ulps);
+        failures += Tests.testUlpDiff("StrictMath.log1p(double",
+                                      input, StrictMath.log1p(input),
+                                      expected, ulps);
+        return failures;
+    }
+
+    public static void main(String argv[]) {
+        int failures = 0;
+
+        failures += testLog1p();
+
+        if (failures > 0) {
+            System.err.println("Testing log1p incurred "
+                               + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Math/MinMax.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,124 @@
+/*
+ * Copyright 1997 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @bug 4010528 4010529
+   @summary Math.min and Math.max should treat negative zero as strictly
+            less than positive zero
+ */
+
+
+public class MinMax {
+
+
+    static void go(String what, float result, float correctResult) {
+        String v = what + ": got " + result + ", expected " + correctResult;
+        if (!(Float.toString(result).equals(Float.toString(correctResult))))
+            throw new RuntimeException(v);
+        System.err.println(v);
+    }
+
+    static void go(String what, double result, double correctResult) {
+        String v = what + ": got " + result + ", expected " + correctResult;
+        if (!(Double.toString(result).equals(Double.toString(correctResult))))
+            throw new RuntimeException(v);
+        System.err.println(v);
+    }
+
+
+    public static void main(String[] args) {
+
+        float fnz = -0.0f;
+        float fpz = +0.0f;
+
+        go("Math.min(fnz, fnz)", Math.min(fnz, fnz), fnz);
+        go("Math.min(fnz, fpz)", Math.min(fnz, fpz), fnz);
+        go("Math.min(fpz, fnz)", Math.min(fpz, fnz), fnz);
+        go("Math.min(fpz, fpz)", Math.min(fpz, fpz), fpz);
+
+        go("Math.min(-1.0f, fnz)", Math.min(-1.0f, fnz), -1.0f);
+        go("Math.min(-1.0f, fpz)", Math.min(-1.0f, fpz), -1.0f);
+        go("Math.min(+1.0f, fnz)", Math.min(+1.0f, fnz), fnz);
+        go("Math.min(+1.0f, fpz)", Math.min(+1.0f, fpz), fpz);
+        go("Math.min(-1.0f, +1.0f)", Math.min(-1.0f, +1.0f), -1.0f);
+        go("Math.min(fnz, -1.0f)", Math.min(fnz, -1.0f), -1.0f);
+        go("Math.min(fpz, -1.0f)", Math.min(fpz, -1.0f), -1.0f);
+        go("Math.min(fnz, +1.0f)", Math.min(fnz, +1.0f), fnz);
+        go("Math.min(fpz, +1.0f)", Math.min(fpz, +1.0f), fpz);
+        go("Math.min(+1.0f, -1.0f)", Math.min(+1.0f, -1.0f), -1.0f);
+
+        go("Math.max(fnz, fnz)", Math.max(fnz, fnz), fnz);
+        go("Math.max(fnz, fpz)", Math.max(fnz, fpz), fpz);
+        go("Math.max(fpz, fnz)", Math.max(fpz, fnz), fpz);
+        go("Math.max(fpz, fpz)", Math.max(fpz, fpz), fpz);
+
+        go("Math.max(-1.0f, fnz)", Math.max(-1.0f, fnz), fnz);
+        go("Math.max(-1.0f, fpz)", Math.max(-1.0f, fpz), fpz);
+        go("Math.max(+1.0f, fnz)", Math.max(+1.0f, fnz), +1.0f);
+        go("Math.max(+1.0f, fpz)", Math.max(+1.0f, fpz), +1.0f);
+        go("Math.max(-1.0f, +1.0f)", Math.max(-1.0f, +1.0f), +1.0f);
+        go("Math.max(fnz, -1.0f)", Math.max(fnz, -1.0f), fnz);
+        go("Math.max(fpz, -1.0f)", Math.max(fpz, -1.0f), fpz);
+        go("Math.max(fnz, +1.0f)", Math.max(fnz, +1.0f), +1.0f);
+        go("Math.max(fpz, +1.0f)", Math.max(fpz, +1.0f), +1.0f);
+        go("Math.max(+1.0f, -1.0f)", Math.max(+1.0f, -1.0f), +1.0f);
+
+
+        double dnz = -0.0d;
+        double dpz = +0.0d;
+
+        go("Math.min(dnz, dnz)", Math.min(dnz, dnz), dnz);
+        go("Math.min(dnz, dpz)", Math.min(dnz, dpz), dnz);
+        go("Math.min(dpz, dnz)", Math.min(dpz, dnz), dnz);
+        go("Math.min(dpz, dpz)", Math.min(dpz, dpz), dpz);
+
+        go("Math.min(-1.0d, dnz)", Math.min(-1.0d, dnz), -1.0d);
+        go("Math.min(-1.0d, dpz)", Math.min(-1.0d, dpz), -1.0d);
+        go("Math.min(+1.0d, dnz)", Math.min(+1.0d, dnz), dnz);
+        go("Math.min(+1.0d, dpz)", Math.min(+1.0d, dpz), dpz);
+        go("Math.min(-1.0d, +1.0d)", Math.min(-1.0d, +1.0d), -1.0d);
+        go("Math.min(dnz, -1.0d)", Math.min(dnz, -1.0d), -1.0d);
+        go("Math.min(dpz, -1.0d)", Math.min(dpz, -1.0d), -1.0d);
+        go("Math.min(dnz, +1.0d)", Math.min(dnz, +1.0d), dnz);
+        go("Math.min(dpz, +1.0d)", Math.min(dpz, +1.0d), dpz);
+        go("Math.min(+1.0d, -1.0d)", Math.min(+1.0d, -1.0d), -1.0d);
+
+        go("Math.max(dnz, dnz)", Math.max(dnz, dnz), dnz);
+        go("Math.max(dnz, dpz)", Math.max(dnz, dpz), dpz);
+        go("Math.max(dpz, dnz)", Math.max(dpz, dnz), dpz);
+        go("Math.max(dpz, dpz)", Math.max(dpz, dpz), dpz);
+
+        go("Math.max(-1.0d, dnz)", Math.max(-1.0d, dnz), dnz);
+        go("Math.max(-1.0d, dpz)", Math.max(-1.0d, dpz), dpz);
+        go("Math.max(+1.0d, dnz)", Math.max(+1.0d, dnz), +1.0d);
+        go("Math.max(+1.0d, dpz)", Math.max(+1.0d, dpz), +1.0d);
+        go("Math.max(-1.0d, +1.0d)", Math.max(-1.0d, +1.0d), +1.0d);
+        go("Math.max(dnz, -1.0d)", Math.max(dnz, -1.0d), dnz);
+        go("Math.max(dpz, -1.0d)", Math.max(dpz, -1.0d), dpz);
+        go("Math.max(dnz, +1.0d)", Math.max(dnz, +1.0d), +1.0d);
+        go("Math.max(dpz, +1.0d)", Math.max(dpz, +1.0d), +1.0d);
+        go("Math.max(+1.0d, -1.0d)", Math.max(+1.0d, -1.0d), +1.0d);
+
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Math/PowTests.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,301 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4984407 5033578
+ * @summary Tests for {Math, StrictMath}.pow
+ * @compile -source 1.5 PowTests.java
+ * @run main PowTests
+ * @author Joseph D. Darcy
+ */
+
+public class PowTests {
+    private PowTests(){}
+
+    static final double infinityD = Double.POSITIVE_INFINITY;
+
+    static int testPowCase(double input1, double input2, double expected) {
+        int failures = 0;
+        failures += Tests.test("StrictMath.pow(double, double)", input1, input2,
+                               StrictMath.pow(input1, input2), expected);
+        failures += Tests.test("Math.pow(double, double)", input1, input2,
+                               Math.pow(input1, input2), expected);
+        return failures;
+    }
+
+
+    static int testStrictPowCase(double input1, double input2, double expected) {
+        int failures = 0;
+        failures += Tests.test("StrictMath.pow(double, double)", input1, input2,
+                               StrictMath.pow(input1, input2), expected);
+        return failures;
+    }
+
+    static int testNonstrictPowCase(double input1, double input2, double expected) {
+        int failures = 0;
+        failures += Tests.test("Math.pow(double, double)", input1, input2,
+                               Math.pow(input1, input2), expected);
+        return failures;
+    }
+
+    /*
+     * Test for bad negation implementation.
+     */
+    static int testPow() {
+        int failures = 0;
+
+        double [][] testCases = {
+            {-0.0,               3.0,   -0.0},
+            {-0.0,               4.0,    0.0},
+            {-infinityD,        -3.0,   -0.0},
+            {-infinityD,        -4.0,    0.0},
+        };
+
+        for (double[] testCase : testCases) {
+            failures+=testPowCase(testCase[0], testCase[1], testCase[2]);
+        }
+
+        return failures;
+    }
+
+    /*
+     * Test cross-product of different kinds of arguments.
+     */
+    static int testCrossProduct() {
+        int failures = 0;
+
+        double testData[] = {
+                                Double.NEGATIVE_INFINITY,
+/* > -oo */                     -Double.MAX_VALUE,
+/**/                            (double)Long.MIN_VALUE,
+/**/                            (double) -((1L<<53)+2L),
+/**/                            (double) -((1L<<53)),
+/**/                            (double) -((1L<<53)-1L),
+/**/                            -((double)Integer.MAX_VALUE + 4.0),
+/**/                            (double)Integer.MIN_VALUE - 1.0,
+/**/                            (double)Integer.MIN_VALUE,
+/**/                            (double)Integer.MIN_VALUE + 1.0,
+/**/                            -Math.PI,
+/**/                            -3.0,
+/**/                            -Math.E,
+/**/                            -2.0,
+/**/                            -1.0000000000000004,
+/* < -1.0 */                    -1.0000000000000002, // nextAfter(-1.0, -oo)
+                                -1.0,
+/* > -1.0 */                    -0.9999999999999999, // nextAfter(-1.0, +oo)
+/* > -1.0 */                    -0.9999999999999998,
+/**/                            -0.5,
+/**/                            -1.0/3.0,
+/* < 0.0 */                     -Double.MIN_VALUE,
+                                -0.0,
+                                +0.0,
+/* > 0.0 */                     +Double.MIN_VALUE,
+/**/                            +1.0/3.0,
+/**/                            +0.5,
+/**/                            +0.9999999999999998,
+/* < +1.0 */                    +0.9999999999999999, // nextAfter(-1.0, +oo)
+                                +1.0,
+/* > 1.0 */                     +1.0000000000000002, // nextAfter(+1.0, +oo)
+/**/                            +1.0000000000000004,
+/**/                            +2.0,
+/**/                            +Math.E,
+/**/                            +3.0,
+/**/                            +Math.PI,
+/**/                            -(double)Integer.MIN_VALUE - 1.0,
+/**/                            -(double)Integer.MIN_VALUE,
+/**/                            -(double)Integer.MIN_VALUE + 1.0,
+/**/                            (double)Integer.MAX_VALUE + 4.0,
+/**/                            (double) ((1L<<53)-1L),
+/**/                            (double) ((1L<<53)),
+/**/                            (double) ((1L<<53)+2L),
+/**/                            -(double)Long.MIN_VALUE,
+/* < oo */                      Double.MAX_VALUE,
+                                Double.POSITIVE_INFINITY,
+                                Double.NaN
+    };
+
+        double NaN = Double.NaN;
+        for(double x: testData) {
+            for(double y: testData) {
+                boolean testPass = false;
+                double expected=NaN;
+                double actual;
+
+                // First, switch on y
+                if( Double.isNaN(y)) {
+                    expected = NaN;
+                } else if (y == 0.0) {
+                    expected = 1.0;
+                } else if (Double.isInfinite(y) ) {
+                    if(y > 0) { // x ^ (+oo)
+                        if (Math.abs(x) > 1.0) {
+                            expected = Double.POSITIVE_INFINITY;
+                        } else if (Math.abs(x) == 1.0) {
+                            expected = NaN;
+                        } else if (Math.abs(x) < 1.0) {
+                            expected = +0.0;
+                        } else { // x is NaN
+                            assert Double.isNaN(x);
+                            expected = NaN;
+                        }
+                    } else { // x ^ (-oo)
+                        if (Math.abs(x) > 1.0) {
+                            expected = +0.0;
+                        } else if (Math.abs(x) == 1.0) {
+                            expected = NaN;
+                        } else if (Math.abs(x) < 1.0) {
+                            expected = Double.POSITIVE_INFINITY;
+                        } else { // x is NaN
+                            assert Double.isNaN(x);
+                            expected = NaN;
+                        }
+                    } /* end Double.isInfinite(y) */
+                } else if (y == 1.0) {
+                    expected = x;
+                } else if (Double.isNaN(x)) { // Now start switching on x
+                    assert y != 0.0;
+                    expected = NaN;
+                } else if (x == Double.NEGATIVE_INFINITY) {
+                    expected = (y < 0.0) ? f2(y) :f1(y);
+                } else if (x == Double.POSITIVE_INFINITY) {
+                    expected = (y < 0.0) ? +0.0 : Double.POSITIVE_INFINITY;
+                } else if (equivalent(x, +0.0)) {
+                    assert y != 0.0;
+                    expected = (y < 0.0) ? Double.POSITIVE_INFINITY: +0.0;
+                } else if (equivalent(x, -0.0)) {
+                    assert y != 0.0;
+                    expected = (y < 0.0) ? f1(y): f2(y);
+                } else if( x < 0.0) {
+                    assert y != 0.0;
+                    failures += testStrictPowCase(x, y, f3(x, y));
+                    failures += testNonstrictPowCase(x, y, f3ns(x, y));
+                    continue;
+                } else {
+                    // go to next iteration
+                    expected = NaN;
+                    continue;
+                }
+
+                failures += testPowCase(x, y, expected);
+            } // y
+        } // x
+        return failures;
+    }
+
+    static boolean equivalent(double a, double b) {
+        return Double.compare(a, b) == 0;
+    }
+
+    static double f1(double y) {
+        return (intClassify(y) == 1)?
+            Double.NEGATIVE_INFINITY:
+            Double.POSITIVE_INFINITY;
+    }
+
+
+    static double f2(double y) {
+        return (intClassify(y) == 1)?-0.0:0.0;
+    }
+
+    static double f3(double x, double y) {
+        switch( intClassify(y) ) {
+        case 0:
+            return StrictMath.pow(Math.abs(x), y);
+            // break;
+
+        case 1:
+            return -StrictMath.pow(Math.abs(x), y);
+            // break;
+
+        case -1:
+            return Double.NaN;
+            // break;
+
+        default:
+            throw new AssertionError("Bad classification.");
+            // break;
+        }
+    }
+
+    static double f3ns(double x, double y) {
+        switch( intClassify(y) ) {
+        case 0:
+            return Math.pow(Math.abs(x), y);
+            // break;
+
+        case 1:
+            return -Math.pow(Math.abs(x), y);
+            // break;
+
+        case -1:
+            return Double.NaN;
+            // break;
+
+        default:
+            throw new AssertionError("Bad classification.");
+            // break;
+        }
+    }
+
+    static boolean isFinite(double a) {
+        return (0.0*a  == 0);
+    }
+
+    /**
+     * Return classification of argument: -1 for non-integers, 0 for
+     * even integers, 1 for odd integers.
+     */
+    static int intClassify(double a) {
+        if(!isFinite(a) || // NaNs and infinities
+           (a != Math.floor(a) )) { // only integers are fixed-points of floor
+                return -1;
+        }
+        else {
+            // Determine if argument is an odd or even integer.
+
+            a = StrictMath.abs(a); // absolute value doesn't affect odd/even
+
+            if(a+1.0 == a) { // a > maximum odd floating-point integer
+                return 0; // Large integers are all even
+            }
+            else { // Convert double -> long and look at low-order bit
+                long ell = (long)  a;
+                return ((ell & 0x1L) == (long)1)?1:0;
+            }
+        }
+    }
+
+    public static void main(String [] argv) {
+        int failures = 0;
+
+        failures += testPow();
+        failures += testCrossProduct();
+
+        if (failures > 0) {
+            System.err.println("Testing pow incurred "
+                               + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Math/Rint.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,122 @@
+/*
+ * Copyright 1998-2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4101566 4831589
+ * @summary Check for correct implementation of Math.rint(double)
+ *
+ */
+
+import sun.misc.FpUtils;
+import sun.misc.DoubleConsts;
+
+public class Rint {
+
+    static int testRintCase(double input, double expected) {
+        int failures = 0;
+        double result;
+        failures += Tests.test("Math.rint",  input, Math.rint(input),   expected);
+        failures += Tests.test("Math.rint", -input, Math.rint(-input), -expected);
+        failures += Tests.test("StrictMath.rint",
+                               input, StrictMath.rint(input),   expected);
+        failures += Tests.test("StrictMath.rint", -input,
+                               StrictMath.rint(-input), -expected);
+        return failures;
+    }
+
+
+    public static void main(String args[]) {
+        int failures = 0;
+        double twoToThe52 = FpUtils.scalb(1.0, 52); // 2^52
+
+        double [][] testCases = {
+            {0.0,                               0.0},
+            {Double.MIN_VALUE,                  0.0},
+            {FpUtils.nextDown(DoubleConsts.MIN_NORMAL), 0.0},
+            {DoubleConsts.MIN_NORMAL,           0.0},
+
+            {0.2,                               0.0},
+
+            {FpUtils.nextDown(0.5),             0.0},
+            {                 0.5,              0.0},
+            {  FpUtils.nextUp(0.5),             1.0},
+
+            {0.7,                               1.0},
+            {FpUtils.nextDown(1.0),             1.0},
+            {                 1.0,              1.0},
+            {  FpUtils.nextUp(1.0),             1.0},
+
+            {FpUtils.nextDown(1.5),             1.0},
+            {                 1.5,              2.0},
+            {  FpUtils.nextUp(1.5),             2.0},
+
+            {4.2,                               4.0},
+            {4.5,                               4.0},
+            {4.7,                               5.0},
+
+            {7.5,                               8.0},
+            {7.2,                               7.0},
+            {7.7,                               8.0},
+
+            {150000.75,                         150001.0},
+            {300000.5,                          300000.0},
+            {FpUtils.nextUp(300000.5),          300001.0},
+            {FpUtils.nextDown(300000.75),       300001.0},
+            {300000.75,                         300001.0},
+            {FpUtils.nextUp(300000.75),         300001.0},
+            {300000.99,                         300001.0},
+            {262144.75,                         262145.0}, //(2^18 ) + 0.75
+            {499998.75,                         499999.0},
+            {524287.75,                         524288.0}, //(2^19 -1) + 0.75
+            {524288.75,                         524289.0},
+
+            {FpUtils.nextDown(twoToThe52),      twoToThe52},
+            {twoToThe52,                        twoToThe52},
+            {FpUtils.nextUp(twoToThe52),        FpUtils.nextUp(twoToThe52)},
+
+            {Double.MAX_VALUE,          Double.MAX_VALUE},
+            {Double.POSITIVE_INFINITY,  Double.POSITIVE_INFINITY},
+            {Double.NaN,                        Double.NaN}
+
+        };
+
+
+        for(int i = 0; i < testCases.length; i++) {
+            failures += testRintCase(testCases[i][0], testCases[i][1]);
+        }
+
+        // Test values throughout exponent range
+        for(double d = Double.MIN_VALUE;
+            d < Double.POSITIVE_INFINITY; d *= 2) {
+            failures += testRintCase(d, ((d<=0.5)?0.0:d));
+        }
+
+        if (failures > 0) {
+            System.err.println("Testing {Math, StrictMath}.rint incurred "
+                               + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Math/TanTests.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,189 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 5033578
+ * @summary Tests for {Math, StrictMath}.tan
+ * @compile -source 1.5 TanTests.java
+ * @run main TanTests
+ * @author Joseph D. Darcy
+ */
+
+public class TanTests {
+    private TanTests(){}
+
+    static int testTanCase(double input, double expected, double ulps) {
+        int failures = 0;
+        failures += Tests.testUlpDiff("StrictMath.tan(double, double)", input,
+                               StrictMath.tan(input), expected, ulps);
+        failures += Tests.testUlpDiff("Math.tan(double, double)", input,
+                               Math.tan(input), expected, ulps);
+        return failures;
+    }
+
+    static int testTan() {
+        int failures = 0;
+
+        double [][] testCases = {
+            // 1.1 ulp case from Gonnet
+            {0x1.31b97c4000001p24,      -0x1.d08538b656222p34,  1.9},
+            // Remaining test cases adapted from work by Alex Liu
+            {0x1.be1b2d17ba207p6, -0x1.cf489c89f8066p49, 1.100000},
+            {0x1.e0a9e6ab97de7p7, 0x1.d31ce95f57459p50, 1.100000},
+            {0x1.23f8c5bcf003ep11, 0x1.f022585dbb50ap50, 1.100000},
+            {0x1.44bdb557e1dc1p20, 0x1.b67eaf362701fp49, 1.100000},
+            {0x1.604759040fb6fp68, 0x1.d574bc1f9e903p50, 1.100000},
+            {0x1.3d33fa4e5ba47p70, 0x1.ce1dd6e33fef8p49, 1.100000},
+            {0x1.f19e5d71b26bap85, 0x1.c2536a9119dd2p55, 1.100000},
+            {0x1.43ed062d2d62cp88, -0x1.c94b0c5b7b05p49, 1.100000},
+            {0x1.b7b895b030bep88, -0x1.cba9ebb0f20b9p51, 1.100000},
+            {0x1.a86090fe7c144p95, 0x1.d5ad72ca48bbfp48, 1.100000},
+            {0x1.d199df0700a61p95, -0x1.b8dd636f8dba7p49, 1.100000},
+            {0x1.d713037d1d222p106, -0x1.d57f035fd0146p48, 1.100000},
+            {0x1.ed1f6b066569bp115, 0x1.840af46cc9bep48, 1.100000},
+            {0x1.16800a51eff75p118, 0x1.c9f91caf08a6ap49, 1.100000},
+            {0x1.c1169c1040ecdp134, 0x1.e44a7eb56cb7p48, 1.100000},
+            {0x1.19b0fb40dddd5p145, -0x1.f1b1c235774b2p48, 1.100000},
+            {0x1.4d6b47f2480f8p162, 0x1.da1c2010795a5p51, 1.100000},
+            {0x1.682ff8e5429ddp163, -0x1.95a7aee1e93bep55, 1.100000},
+            {0x1.d0569fad9657dp204, -0x1.8f2ca17123aa5p49, 1.100000},
+            {0x1.55505de5bbc14p206, -0x1.e8d28e39ddf9p50, 1.100000},
+            {0x1.cf497083e6c77p206, -0x1.fd3fbaa40de18p49, 1.100000},
+            {0x1.c5b30c8686203p214, 0x1.f4d14469638a9p48, 1.100000},
+            {0x1.60d15b12ff0b7p217, 0x1.bc150932bd3d7p48, 1.100000},
+            {0x1.07cc6858d980bp218, -0x1.f3f7355c983a5p51, 1.100000},
+            {0x1.e06a67cd86969p218, 0x1.b0873124d98afp51, 1.100000},
+            {0x1.49704174c38e3p229, 0x1.e0301142ccbc2p49, 1.100000},
+            {0x1.ea19ceab3b06ap230, -0x1.fc22e687f0482p48, 1.100000},
+            {0x1.0c905503fea72p236, -0x1.7d4e9a45014d5p49, 1.100000},
+            {0x1.28eb1f8ddd7c3p257, -0x1.a951893680c71p49, 1.100000},
+            {0x1.310b11af2bfbep260, 0x1.84d458039c2e6p48, 1.100000},
+            {0x1.f3c172bb7afc2p265, -0x1.fb3139d3ba04fp49, 1.100000},
+            {0x1.54a28326cfedep267, 0x1.f416de8fb60bap53, 1.100000},
+            {0x1.5a5154d9d609dp269, -0x1.83d74cea8141p51, 1.100000},
+            {0x1.3ee75fd803b21p275, 0x1.b9ab67b61bf65p50, 1.100000},
+            {0x1.f4a4c781834d9p277, -0x1.d639ec63bf3b6p49, 1.100000},
+            {0x1.2053d5c14cf78p279, 0x1.fc31413372cdcp50, 1.100000},
+            {0x1.896d0a9acee4cp298, 0x1.f9136d6e27a5cp48, 1.100000},
+            {0x1.f010da08a862p302, -0x1.fd812c5e13483p49, 1.100000},
+            {0x1.65f2e272f729fp308, -0x1.f9f642ddaa32dp49, 1.100000},
+            {0x1.a8afbc4edb07dp309, 0x1.fa0d458320902p52, 1.100000},
+            {0x1.4d311a5447cdep329, -0x1.f7e98fe193e81p49, 1.100000},
+            {0x1.808f66338b21bp345, -0x1.bceaf45f61155p49, 1.100000},
+            {0x1.5a34aacf5ded1p350, 0x1.d41f0f13fadd4p49, 1.100000},
+            {0x1.3e8b85532bad1p354, -0x1.f0b21179d663ep49, 1.100000},
+            {0x1.1c2ecf01570acp394, -0x1.c215c9e2b7b24p49, 1.100000},
+            {0x1.666eba99d2837p402, 0x1.fbd5c4b527506p48, 1.100000},
+            {0x1.6cc39f07fafbbp460, -0x1.f087548a00e7cp49, 1.100000},
+            {0x1.9481228fea3ffp463, -0x1.c585e64ff44c8p48, 1.100000},
+            {0x1.79c3af0b4d0d4p466, 0x1.c9ed3716691f2p51, 1.100000},
+            {0x1.993ea84c3e23bp468, 0x1.a6b3954fc37f3p49, 1.100000},
+            {0x1.cfd6b13f64408p470, -0x1.f4db7cc2c09bp47, 1.100000},
+            {0x1.b820ccdd52299p473, 0x1.77a1ff863b0f3p52, 1.100000},
+            {0x1.157ef3a1528a5p475, -0x1.f4e14ddc45e49p51, 1.100000},
+            {0x1.b492a8997bc36p478, -0x1.e0db26b7f03e8p48, 1.100000},
+            {0x1.e0ea5674b831bp480, 0x1.e0ad6b3cdccdfp48, 1.100000},
+            {0x1.c62ac8b32cb9ep497, 0x1.c95d00a36f677p48, 1.100000},
+            {0x1.467f1daf12b43p498, 0x1.c6d3fdc096f0bp50, 1.100000},
+            {0x1.336e5a83e390cp502, 0x1.fc873dae28572p48, 1.100000},
+            {0x1.aaab1de0d6727p506, -0x1.e0482967d0354p49, 1.100000},
+            {0x1.e5ce06a12139cp507, 0x1.cea42e29735bdp49, 1.100000},
+            {0x1.87dad74d0dda8p516, -0x1.b2cde6c0a8b9fp48, 1.100000},
+            {0x1.e4feb94ee0989p524, -0x1.b227d0d0ffaa8p49, 1.100000},
+            {0x1.31c082b1361ebp525, 0x1.a7ed49158d736p49, 1.100000},
+            {0x1.56913865b3e16p531, 0x1.eeb7a32591c3bp52, 1.100000},
+            {0x1.36ade1fa883cap544, -0x1.fa087aadc0cbp48, 1.100000},
+            {0x1.de57314df4af8p559, 0x1.c686aa5a41075p49, 1.100000},
+            {0x1.0bb29bf7960ddp586, -0x1.d29ae1a3023cep50, 1.100000},
+            {0x1.049a584685941p588, -0x1.eebfb159dba67p51, 1.100000},
+            {0x1.33c1d4257b294p589, 0x1.ea1eedabea109p48, 1.100000},
+            {0x1.3587e511bf47bp590, 0x1.c897858ce0ca9p48, 1.100000},
+            {0x1.d12ee010c0facp590, 0x1.ab5b4b5065aa3p48, 1.100000},
+            {0x1.87bbed5af48d9p605, 0x1.f512c3b2be7cap50, 1.100000},
+            {0x1.a0b1131240cebp605, -0x1.fa373983fd571p48, 1.100000},
+            {0x1.116fdda1a04c9p616, -0x1.d76fdbc8552f3p51, 1.100000},
+            {0x1.67ebae833a034p620, 0x1.e1313af0a4075p50, 1.100000},
+            {0x1.9a50fbc5b0fecp627, 0x1.d89150884fbf7p50, 1.100000},
+            {0x1.6d625e0757e9cp631, -0x1.d0a5ecf002555p49, 1.100000},
+            {0x1.e880344cc9913p636, -0x1.fafd04caaf58bp48, 1.100000},
+            {0x1.e0a180b843cc5p650, 0x1.ea2aea3b8c953p49, 1.100000},
+            {0x1.fa91ce15157b2p652, 0x1.e6f5f4d47d83fp48, 1.100000},
+            {0x1.7696347caf8dfp654, 0x1.e0d36f2aef7dap51, 1.100000},
+            {0x1.886484b536161p666, -0x1.e3c96481e335bp51, 1.100000},
+            {0x1.0aa3ff2b41abdp675, -0x1.b3300ee04b4c8p50, 1.100000},
+            {0x1.d695ac08fe897p675, -0x1.c27fd21ecb13p51, 1.100000},
+            {0x1.4c1e532d7a99ap680, 0x1.e2ec695260c39p49, 1.100000},
+            {0x1.44a9f3e395802p685, -0x1.e7273ab9ce8e2p52, 1.100000},
+            {0x1.3a25ec2b43d45p697, -0x1.d23187ba6321ep49, 1.100000},
+            {0x1.96f5c2420c3fdp716, -0x1.ea06ab71ad719p49, 1.100000},
+            {0x1.926c063a9406bp741, 0x1.e3d3d9262fd66p48, 1.100000},
+            {0x1.1a57713d6fd93p754, -0x1.c10074d49490dp48, 1.100000},
+            {0x1.739387922e672p772, 0x1.bda527e215a3cp49, 1.100000},
+            {0x1.d286eff17f4d4p793, 0x1.d01c678ebfa1p49, 1.100000},
+            {0x1.f3d777206a062p794, -0x1.d8604b6d18385p49, 1.100000},
+            {0x1.ae91e6574da91p826, -0x1.fd1b26ab656c2p49, 1.100000},
+            {0x1.4422b3c871c9p836, 0x1.9d2cab1f3aebcp48, 1.100000},
+            {0x1.7ff8537071e1p840, 0x1.badde451c6ed7p48, 1.100000},
+            {0x1.c6fe9202e219dp845, -0x1.b2aa20745de3p51, 1.100000},
+            {0x1.a95a0b4015d88p846, 0x1.cdf5dfd045657p50, 1.100000},
+            {0x1.f823b9cff0daep867, 0x1.fd72fce3d5505p48, 1.100000},
+            {0x1.a6bee2afcd2fp886, 0x1.fe06265cd3aebp49, 1.100000},
+            {0x1.7b034b3412d17p892, 0x1.e48055812d391p50, 1.100000},
+            {0x1.58588f8cda276p894, 0x1.f806fddf0dd05p53, 1.100000},
+            {0x1.ce750a7963463p896, 0x1.e94f1f4018402p48, 1.100000},
+            {0x1.3d50a91fe82cfp897, 0x1.cd518fda10e95p48, 1.100000},
+            {0x1.f82dea1c0b809p897, -0x1.d6a0ef08179c5p48, 1.100000},
+            {0x1.38673e8c6a4afp903, 0x1.f4113a036478p48, 1.100000},
+            {0x1.dfb75e4a7432p911, 0x1.eb7bc6cb4d7f3p48, 1.100000},
+            {0x1.1230b975a72b3p916, -0x1.e1042be0759f9p48, 1.100000},
+            {0x1.302c2f5a4e6e5p916, 0x1.f66a9874cd60ap48, 1.100000},
+            {0x1.04e07a1d67b93p921, 0x1.87735139f6a0bp53, 1.100000},
+            {0x1.5a3eb79cd06fap931, -0x1.e00930c219ef3p51, 1.100000},
+            {0x1.8fb45679936fp937, 0x1.9a427588645c4p50, 1.100000},
+            {0x1.c4abb225260c6p964, -0x1.d1e64e91ac6ap50, 1.100000},
+            {0x1.b43e449b25382p982, -0x1.f1848cc5ac4fep50, 1.100000},
+            {0x1.504d9d7179b1ap983, 0x1.a4e51ea807786p48, 1.100000},
+            {0x1.83a5af80fb39bp987, 0x1.a6dde6c2220ebp48, 1.100000},
+            {0x1.5d978d9ad84c8p1011, 0x1.ec96900bfd1ddp51, 1.100000},
+        };
+
+        for(double[] testCase: testCases) {
+            failures += testTanCase(testCase[0], testCase[1], testCase[2]);
+        }
+
+        return failures;
+    }
+
+    public static void main(String [] argv) {
+        int failures = 0;
+
+        failures += testTan();
+
+        if (failures > 0) {
+            System.err.println("Testing tan incurred "
+                               + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Math/Tests.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,341 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * Shared static test methods for numerical tests.  Sharing these
+ * helper test methods avoids repeated functions in the various test
+ * programs.  The test methods return 1 for a test failure and 0 for
+ * success.  The order of arguments to the test methods is generally
+ * the test name, followed by the test arguments, the computed result,
+ * and finally the expected result.
+ */
+
+import sun.misc.FpUtils;
+
+public class Tests {
+    private Tests(){}; // do not instantiate
+
+    private static String toHexString(float f) {
+        if (!Float.isNaN(f))
+            return Float.toHexString(f);
+        else
+            return "NaN(0x" + Integer.toHexString(Float.floatToRawIntBits(f)) + ")";
+    }
+
+    private static String toHexString(double d) {
+        if (!Double.isNaN(d))
+            return Double.toHexString(d);
+        else
+            return "NaN(0x" + Long.toHexString(Double.doubleToRawLongBits(d)) + ")";
+    }
+
+    public static int test(String testName, float input,
+                           boolean result, boolean expected) {
+        if (expected != result) {
+            System.err.println("Failure for " + testName + ":\n" +
+                               "\tFor input " + input    + "\t(" + toHexString(input) + ")\n" +
+                               "\texpected  " + expected + "\n"  +
+                               "\tgot       " + result   + ").");
+            return 1;
+        }
+        else
+            return 0;
+    }
+
+    public static int test(String testName, double input,
+                           boolean result, boolean expected) {
+        if (expected != result) {
+            System.err.println("Failure for " + testName + ":\n" +
+                               "\tFor input " + input    + "\t(" + toHexString(input) + ")\n" +
+                               "\texpected  " + expected + "\n"  +
+                               "\tgot       " + result   + ").");
+            return 1;
+        }
+        else
+            return 0;
+    }
+
+    public static int test(String testName, float input1, float input2,
+                           boolean result, boolean expected) {
+        if (expected != result) {
+            System.err.println("Failure for "  + testName + ":\n" +
+                               "\tFor inputs " + input1   + "\t(" + toHexString(input1) + ") and "
+                                               + input2   + "\t(" + toHexString(input2) + ")\n" +
+                               "\texpected  "  + expected + "\n"  +
+                               "\tgot       "  + result   + ").");
+            return 1;
+        }
+        return 0;
+    }
+
+    public static int test(String testName, double input1, double input2,
+                           boolean result, boolean expected) {
+        if (expected != result) {
+            System.err.println("Failure for "  + testName + ":\n" +
+                               "\tFor inputs " + input1   + "\t(" + toHexString(input1) + ") and "
+                                               + input2   + "\t(" + toHexString(input2) + ")\n" +
+                               "\texpected  "  + expected + "\n"  +
+                               "\tgot       "  + result   + ").");
+            return 1;
+        }
+        return 0;
+    }
+
+    public static int test(String testName, float input,
+                           int result, int expected) {
+        if (expected != result) {
+            System.err.println("Failure for " + testName + ":\n" +
+                               "\tFor input " + input    + "\t(" + toHexString(input) + ")\n" +
+                               "\texpected  " + expected + "\n" +
+                               "\tgot       " + result    + ").");
+            return 1;
+        }
+        return 0;
+    }
+
+    public  static int test(String testName, double input,
+                            int result, int expected) {
+        if (expected != result) {
+            System.err.println("Failure for " + testName + ":\n" +
+                               "\tFor input " + input    + "\t(" + toHexString(input) + ")\n" +
+                               "\texpected  " + expected + "\n"  +
+                               "\tgot       " + result   + ").");
+            return 1;
+        }
+        else
+            return 0;
+    }
+
+    public static int test(String testName, float input,
+                           float result, float expected) {
+        if (Float.compare(expected, result) != 0 ) {
+            System.err.println("Failure for " + testName + ":\n" +
+                               "\tFor input " + input    + "\t(" + toHexString(input) + ")\n" +
+                               "\texpected  " + expected + "\t(" + toHexString(expected) + ")\n" +
+                               "\tgot       " + result   + "\t(" + toHexString(result) + ").");
+            return 1;
+        }
+        else
+            return 0;
+    }
+
+
+    public static int test(String testName, double input,
+                           double result, double expected) {
+        if (Double.compare(expected, result ) != 0) {
+            System.err.println("Failure for " + testName + ":\n" +
+                               "\tFor input " + input    + "\t(" + toHexString(input) + ")\n" +
+                               "\texpected  " + expected + "\t(" + toHexString(expected) + ")\n" +
+                               "\tgot       " + result   + "\t(" + toHexString(result) + ").");
+            return 1;
+        }
+        else
+            return 0;
+    }
+
+    public static int test(String testName,
+                           float input1, double input2,
+                           float result, float expected) {
+        if (Float.compare(expected, result ) != 0) {
+            System.err.println("Failure for "  + testName + ":\n" +
+                               "\tFor inputs " + input1   + "\t(" + toHexString(input1) + ") and "
+                                               + input2   + "\t(" + toHexString(input2) + ")\n" +
+                               "\texpected  "  + expected + "\t(" + toHexString(expected) + ")\n" +
+                               "\tgot       "  + result   + "\t(" + toHexString(result) + ").");
+            return 1;
+        }
+        else
+            return 0;
+    }
+
+    public static int test(String testName,
+                           double input1, double input2,
+                           double result, double expected) {
+        if (Double.compare(expected, result ) != 0) {
+            System.err.println("Failure for "  + testName + ":\n" +
+                               "\tFor inputs " + input1   + "\t(" + toHexString(input1) + ") and "
+                                               + input2   + "\t(" + toHexString(input2) + ")\n" +
+                               "\texpected  "  + expected + "\t(" + toHexString(expected) + ")\n" +
+                               "\tgot       "  + result   + "\t(" + toHexString(result) + ").");
+            return 1;
+        }
+        else
+            return 0;
+    }
+
+    public static int test(String testName,
+                           float input1, int input2,
+                           float result, float expected) {
+        if (Float.compare(expected, result ) != 0) {
+            System.err.println("Failure for "  + testName + ":\n" +
+                               "\tFor inputs " + input1   + "\t(" + toHexString(input1) + ") and "
+                                               + input2   + "\n"  +
+                               "\texpected  "  + expected + "\t(" + toHexString(expected) + ")\n" +
+                               "\tgot       "  + result   + "\t(" + toHexString(result) + ").");
+            return 1;
+        }
+        else
+            return 0;
+    }
+
+    public static int test(String testName,
+                           double input1, int input2,
+                           double result, double expected) {
+        if (Double.compare(expected, result ) != 0) {
+            System.err.println("Failure for "  + testName + ":\n" +
+                               "\tFor inputs " + input1   + "\t(" + toHexString(input1) + ") and "
+                                               + input2   + "\n"  +
+                               "\texpected  "  + expected + "\t(" + toHexString(expected) + ")\n" +
+                               "\tgot       "  + result   + "\t(" + toHexString(result) + ").");
+            return 1;
+        }
+        else
+            return 0;
+    }
+
+    static int testUlpCore(double result, double expected, double ulps) {
+        // We assume we won't be unlucky and have an inexact expected
+        // be nextDown(2^i) when 2^i would be the correctly rounded
+        // answer.  This would cause the ulp size to be half as large
+        // as it should be, doubling the measured error).
+
+        if (Double.compare(expected, result) == 0) {
+            return 0;   // result and expected are equivalent
+        } else {
+            if( ulps == 0.0) {
+                // Equivalent results required but not found
+                return 1;
+            } else {
+                double difference = expected - result;
+                if (FpUtils.isUnordered(expected, result) ||
+                    Double.isNaN(difference) ||
+                    // fail if greater than or unordered
+                    !(Math.abs( difference/Math.ulp(expected) ) <= Math.abs(ulps)) ) {
+                    return 1;
+                }
+                else
+                    return 0;
+            }
+        }
+    }
+
+    // One input argument.
+    public static int testUlpDiff(String testName, double input,
+                                  double result, double expected, double ulps) {
+        int code = testUlpCore(result, expected, ulps);
+        if (code == 1) {
+            System.err.println("Failure for " + testName + ":\n" +
+                               "\tFor input " + input    + "\t(" + toHexString(input) + ")\n" +
+                               "\texpected  " + expected + "\t(" + toHexString(expected) + ")\n" +
+                               "\tgot       " + result   + "\t(" + toHexString(result) + ");\n" +
+                               "\tdifference greater than ulp tolerance " + ulps);
+        }
+        return code;
+    }
+
+    // Two input arguments.
+    public static int testUlpDiff(String testName, double input1, double input2,
+                                  double result, double expected, double ulps) {
+        int code = testUlpCore(result, expected, ulps);
+        if (code == 1) {
+            System.err.println("Failure for "  + testName + ":\n" +
+                               "\tFor inputs " + input1   + "\t(" + toHexString(input1) + ") and "
+                                               + input2   + "\t(" + toHexString(input2) + ")\n" +
+                               "\texpected  "  + expected + "\t(" + toHexString(expected) + ")\n" +
+                               "\tgot       "  + result   + "\t(" + toHexString(result) + ");\n" +
+                               "\tdifference greater than ulp tolerance " + ulps);
+        }
+        return code;
+    }
+
+    // For a successful test, the result must be within the ulp bound of
+    // expected AND the result must have absolute value less than or
+    // equal to absBound.
+    public static int testUlpDiffWithAbsBound(String testName, double input,
+                                              double result, double expected,
+                                              double ulps, double absBound) {
+        int code = 0;   // return code value
+
+        if (!(StrictMath.abs(result) <= StrictMath.abs(absBound)) &&
+            !Double.isNaN(expected)) {
+            code = 1;
+        } else
+            code = testUlpCore(result, expected, ulps);
+
+        if (code == 1) {
+            System.err.println("Failure for " + testName + ":\n" +
+                               "\tFor input " + input    + "\t(" + toHexString(input) + ")\n" +
+                               "\texpected  " + expected + "\t(" + toHexString(expected) + ")\n" +
+                               "\tgot       " + result   + "\t(" + toHexString(result) + ");\n" +
+                               "\tdifference greater than ulp tolerance " + ulps +
+                               " or the result has larger magnitude than " + absBound);
+        }
+        return code;
+    }
+
+    // For a successful test, the result must be within the ulp bound of
+    // expected AND the result must have absolute value greater than
+    // or equal to the lowerBound.
+    public static int testUlpDiffWithLowerBound(String testName, double input,
+                                                double result, double expected,
+                                                double ulps, double lowerBound) {
+        int code = 0;   // return code value
+
+        if (!(result >= lowerBound) && !Double.isNaN(expected)) {
+            code = 1;
+        } else
+            code = testUlpCore(result, expected, ulps);
+
+        if (code == 1) {
+            System.err.println("Failure for " + testName +
+                               ":\n" +
+                               "\tFor input "   + input    + "\t(" + toHexString(input) + ")" +
+                               "\n\texpected  " + expected + "\t(" + toHexString(expected) + ")" +
+                               "\n\tgot       " + result   + "\t(" + toHexString(result) + ");" +
+                               "\ndifference greater than ulp tolerance " + ulps +
+                               " or result not greater than or equal to the bound " + lowerBound);
+        }
+        return code;
+    }
+
+    public static int testTolerance(String testName, double input,
+                                    double result, double expected, double tolerance) {
+        if (Double.compare(expected, result ) != 0) {
+            double difference = expected - result;
+            if (FpUtils.isUnordered(expected, result) ||
+                Double.isNaN(difference) ||
+                // fail if greater than or unordered
+                !(Math.abs((difference)/expected) <= StrictMath.pow(10, -tolerance)) ) {
+                System.err.println("Failure for " + testName + ":\n" +
+                                   "\tFor input " + input    + "\t(" + toHexString(input) + ")\n" +
+                                   "\texpected  " + expected + "\t(" + toHexString(expected) + ")\n" +
+                                   "\tgot       " + result   + "\t(" + toHexString(result) + ");\n" +
+                                   "\tdifference greater than tolerance 10^-" + tolerance);
+                return 1;
+            }
+            return 0;
+        }
+        else
+            return 0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Short/ByteSwap.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     4495754
+ * @summary Basic test for int byte swap code on short and char
+ * @author  Josh Bloch
+ */
+
+public class ByteSwap {
+    public static void main(String args[]) {
+        if (Short.reverseBytes((short)0xaabb) != (short)0xbbaa)
+            throw new RuntimeException("short");
+
+        if (Character.reverseBytes((char)0xaabb) != (char)0xbbaa)
+            throw new RuntimeException("char");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Short/Decode.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,98 @@
+/*
+ * Copyright 1998-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4136371 5017980 6576055
+ * @summary Test Short.decode method
+ * @author madbot
+ * @author Joseph D. Darcy
+ */
+
+/**
+ * There are six methods in java.lang.Short which transform strings
+ * into a short or Short value:
+ *
+ * public Short(String s)
+ * public static Short decode(String nm)
+ * public static short parseShort(String s, int radix)
+ * public static short parseShort(String s)
+ * public static Short valueOf(String s, int radix)
+ * public static Short valueOf(String s)
+ *
+ * However, of these only decode has a nontrivial implementation
+ * in that class.
+ */
+public class Decode {
+
+    private static void check(String ashort, short expected) {
+        short sh = (Short.decode(ashort)).shortValue();
+        if (sh != expected)
+            throw new RuntimeException("Short.decode failed. String:" +
+                                                ashort + " Result:" + sh);
+    }
+
+    private static void checkFailure(String val, String message) {
+        try {
+            short n = (Short.decode(val)).shortValue();
+            throw new RuntimeException(message);
+        } catch (NumberFormatException e) { /* Okay */}
+    }
+
+    public static void main(String[] args) throws Exception {
+        check(new String(""+Short.MIN_VALUE), Short.MIN_VALUE);
+        check(new String(""+Short.MAX_VALUE), Short.MAX_VALUE);
+
+        check("10",   (short)10);
+        check("0x10", (short)16);
+        check("0X10", (short)16);
+        check("010",  (short)8);
+        check("#10",  (short)16);
+
+        check("+10",   (short)10);
+        check("+0x10", (short)16);
+        check("+0X10", (short)16);
+        check("+010",  (short)8);
+        check("+#10",  (short)16);
+
+        check("-10",   (short)-10);
+        check("-0x10", (short)-16);
+        check("-0X10", (short)-16);
+        check("-010",  (short)-8);
+        check("-#10",  (short)-16);
+
+        check(Integer.toString((int)Short.MIN_VALUE), Short.MIN_VALUE);
+        check(Integer.toString((int)Short.MAX_VALUE), Short.MAX_VALUE);
+
+        checkFailure("0x-10",   "Short.decode allows negative sign in wrong position.");
+        checkFailure("0x+10",   "Short.decode allows positive sign in wrong position.");
+
+        checkFailure("+",       "Raw plus sign allowed.");
+        checkFailure("-",       "Raw minus sign allowed.");
+
+        checkFailure(Integer.toString((int)Short.MIN_VALUE - 1), "Out of range");
+        checkFailure(Integer.toString((int)Short.MAX_VALUE + 1), "Out of range");
+
+        checkFailure("", "Empty String");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/StrictMath/CubeRootTests.java	Mon Jan 26 19:49:26 2009 -0800
@@ -0,0 +1,473 @@
+/*
+ * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4347132
+ * @summary Tests specifically for StrictMath.cbrt
+ * @author Joseph D. Darcy
+ */
+
+/**
+ * The tests in ../Math/CubeRootTests.java test properties that should
+ * hold for any cube root implementation, including the FDLIBM-based
+ * one required for StrictMath.cbrt.  Therefore, the test cases in
+ * ../Math/CubeRootTests.java are run against both the Math and
+ * StrictMath versions of cube root.  The role of this test is to
+ * verify that the FDLIBM cbrt algorithm is being used by running
+ * golden file tests on values that may vary from one conforming cube
+ * root implementation to another.
+ */
+
+public class CubeRootTests {
+    private CubeRootTests(){}
+
+    static int testCubeRootCase(double input, double expected) {
+        int failures=0;
+
+        double minus_input = -input;
+        double minus_expected = -expected;
+
+        failures+=Tests.test("StrictMath.cbrt(double)", input,
+                             StrictMath.cbrt(input), expected);
+        failures+=Tests.test("StrictMath.cbrt(double)", minus_input,
+                             StrictMath.cbrt(minus_input), minus_expected);
+        return failures;
+    }
+
+    static int testCubeRoot() {
+        int failures = 0;
+        double [][] testCases = {
+            {0x1.ffffffffffffep-766,    0x1.fffffffffffffp-256},
+            {0x1.ffffffffffffep-763,    0x1.fffffffffffffp-255},
+            {0x1.ffffffffffffep-760,    0x1.fffffffffffffp-254},
+            {0x1.ffffffffffffep-757,    0x1.fffffffffffffp-253},
+            {0x1.ffffffffffffep-754,    0x1.fffffffffffffp-252},
+            {0x1.ffffffffffffep-751,    0x1.fffffffffffffp-251},
+            {0x1.ffffffffffffep-748,    0x1.fffffffffffffp-250},
+            {0x1.ffffffffffffep-745,    0x1.fffffffffffffp-249},
+            {0x1.ffffffffffffep-742,    0x1.fffffffffffffp-248},
+            {0x1.ffffffffffffep-739,    0x1.fffffffffffffp-247},
+            {0x1.ffffffffffffep-1006,   0x1.fffffffffffffp-336},
+            {0x1.ffffffffffffep-736,    0x1.fffffffffffffp-246},
+            {0x1.ffffffffffffep-733,    0x1.fffffffffffffp-245},
+            {0x1.ffffffffffffep-730,    0x1.fffffffffffffp-244},
+            {0x1.ffffffffffffep-727,    0x1.fffffffffffffp-243},
+            {0x1.ffffffffffffep-724,    0x1.fffffffffffffp-242},
+            {0x1.ffffffffffffep-721,    0x1.fffffffffffffp-241},
+            {0x1.ffffffffffffep-718,    0x1.fffffffffffffp-240},
+            {0x1.ffffffffffffep-715,    0x1.fffffffffffffp-239},
+            {0x1.ffffffffffffep-712,    0x1.fffffffffffffp-238},
+            {0x1.ffffffffffffep-709,    0x1.fffffffffffffp-237},
+            {0x1.ffffffffffffep-706,    0x1.fffffffffffffp-236},
+            {0x1.ffffffffffffep-703,    0x1.fffffffffffffp-235},
+            {0x1.ffffffffffffep-700,    0x1.fffffffffffffp-234},
+            {0x1.ffffffffffffep-697,    0x1.fffffffffffffp-233},
+            {0x1.ffffffffffffep-694,    0x1.fffffffffffffp-232},
+            {0x1.ffffffffffffep-691,    0x1.fffffffffffffp-231},
+            {0x1.ffffffffffffep-1003,   0x1.fffffffffffffp-335},
+            {0x1.ffffffffffffep-688,    0x1.fffffffffffffp-230},
+            {0x1.ffffffffffffep-685,    0x1.fffffffffffffp-229},
+            {0x1.ffffffffffffep-682,    0x1.fffffffffffffp-228},
+            {0x1.ffffffffffffep-679,    0x1.fffffffffffffp-227},
+            {0x1.ffffffffffffep-676,    0x1.fffffffffffffp-226},
+            {0x1.ffffffffffffep-673,    0x1.fffffffffffffp-225},
+            {0x1.ffffffffffffep-670,    0x1.fffffffffffffp-224},
+            {0x1.ffffffffffffep-667,    0x1.fffffffffffffp-223},
+            {0x1.ffffffffffffep-664,    0x1.fffffffffffffp-222},
+            {0x1.ffffffffffffep-661,    0x1.fffffffffffffp-221},
+            {0x1.ffffffffffffep-658,    0x1.fffffffffffffp-220},
+            {0x1.ffffffffffffep-655,    0x1.fffffffffffffp-219},
+            {0x1.ffffffffffffep-652,    0x1.fffffffffffffp-218},
+            {0x1.ffffffffffffep-649,    0x1.fffffffffffffp-217},
+            {0x1.ffffffffffffep-646,    0x1.fffffffffffffp-216},
+            {0x1.ffffffffffffep-643,    0x1.fffffffffffffp-215},
+            {0x1.ffffffffffffep-1000,   0x1.fffffffffffffp-334},
+            {0x1.ffffffffffffep-640,    0x1.fffffffffffffp-214},
+            {0x1.ffffffffffffep-637,    0x1.fffffffffffffp-213},
+            {0x1.ffffffffffffep-634,    0x1.fffffffffffffp-212},
+            {0x1.ffffffffffffep-631,    0x1.fffffffffffffp-211},
+            {0x1.ffffffffffffep-628,    0x1.fffffffffffffp-210},
+            {0x1.ffffffffffffep-625,    0x1.fffffffffffffp-209},
+            {0x1.ffffffffffffep-622,    0x1.fffffffffffffp-208},
+            {0x1.ffffffffffffep-619,    0x1.fffffffffffffp-207},
+            {0x1.ffffffffffffep-616,    0x1.fffffffffffffp-206},
+            {0x1.ffffffffffffep-613,    0x1.fffffffffffffp-205},
+            {0x1.ffffffffffffep-610,    0x1.fffffffffffffp-204},
+            {0x1.ffffffffffffep-607,    0x1.fffffffffffffp-203},
+            {0x1.ffffffffffffep-604,    0x1.fffffffffffffp-202},
+            {0x1.ffffffffffffep-601,    0x1.fffffffffffffp-201},
+            {0x1.ffffffffffffep-598,    0x1.fffffffffffffp-200},
+            {0x1.ffffffffffffep-595,    0x1.fffffffffffffp-199},
+            {0x1.ffffffffffffep-997,    0x1.fffffffffffffp-333},
+            {0x1.ffffffffffffep-592,    0x1.fffffffffffffp-198},
+            {0x1.ffffffffffffep-589,    0x1.fffffffffffffp-197},
+            {0x1.ffffffffffffep-586,    0x1.fffffffffffffp-196},
+            {0x1.ffffffffffffep-583,    0x1.fffffffffffffp-195},
+            {0x1.ffffffffffffep-580,    0x1.fffffffffffffp-194},
+            {0x1.ffffffffffffep-577,    0x1.fffffffffffffp-193},
+            {0x1.ffffffffffffep-574,    0x1.fffffffffffffp-192},
+            {0x1.ffffffffffffep-571,    0x1.fffffffffffffp-191},
+            {0x1.ffffffffffffep-568,    0x1.fffffffffffffp-190},
+            {0x1.ffffffffffffep-565,    0x1.fffffffffffffp-189},
+            {0x1.ffffffffffffep-562,    0x1.fffffffffffffp-188},
+            {0x1.ffffffffffffep-559,    0x1.fffffffffffffp-187},
+            {0x1.ffffffffffffep-556,    0x1.fffffffffffffp-186},
+            {0x1.ffffffffffffep-553,    0x1.fffffffffffffp-185},
+            {0x1.ffffffffffffep-550,    0x1.fffffffffffffp-184},
+            {0x1.ffffffffffffep-547,    0x1.fffffffffffffp-183},
+            {0x1.ffffffffffffep-994,    0x1.fffffffffffffp-332},
+            {0x1.ffffffffffffep-544,    0x1.fffffffffffffp-182},
+            {0x1.ffffffffffffep-541,    0x1.fffffffffffffp-181},
+            {0x1.ffffffffffffep-538,    0x1.fffffffffffffp-180},
+            {0x1.ffffffffffffep-535,    0x1.fffffffffffffp-179},
+            {0x1.ffffffffffffep-532,    0x1.fffffffffffffp-178},
+            {0x1.ffffffffffffep-529,    0x1.fffffffffffffp-177},
+            {0x0.00000000001fp-1022,    0x1.fa9c313858568p-356},
+            {0x1.ffffffffffffep-526,    0x1.fffffffffffffp-176},
+            {0x1.ffffffffffffep-523,    0x1.fffffffffffffp-175},
+            {0x1.ffffffffffffep-520,    0x1.fffffffffffffp-174},
+            {0x1.ffffffffffffep-517,    0x1.fffffffffffffp-173},
+            {0x0.00000000001fdp-1022,   0x1.feff7f94ea34dp-356},
+            {0x1.ffffffffffffep-514,    0x1.fffffffffffffp-172},
+            {0x0.00000001fffe7p-1022,   0x1.ffff7aaa87f1bp-352},
+            {0x0.00000001fffffp-1022,   0x1.fffffaaaaa9c7p-352},
+            {0x0.00001ffffff4p-1022,    0x1.ffffffcp-348},
+            {0x0.00001ffffffffp-1022,   0x1.ffffffffaaaabp-348},
+            {0x0.01ffffffffffcp-1022,   0x1.ffffffffffeabp-344},
+            {0x1.ffffffffffffep-511,    0x1.fffffffffffffp-171},
+            {0x1.ffffffffffffep-508,    0x1.fffffffffffffp-170},
+            {0x1.ffffffffffffep-505,    0x1.fffffffffffffp-169},
+            {0x1.ffffffffffffep-502,    0x1.fffffffffffffp-168},
+            {0x1.ffffffffffffep-499,    0x1.fffffffffffffp-167},
+            {0x1.ffffffffffffep-991,    0x1.fffffffffffffp-331},
+            {0x1.ffffffffffffep-496,    0x1.fffffffffffffp-166},
+            {0x1.ffffffffffffep-493,    0x1.fffffffffffffp-165},
+            {0x1.ffffffffffffep-490,    0x1.fffffffffffffp-164},
+            {0x1.ffffffffffffep-487,    0x1.fffffffffffffp-163},
+            {0x1.ffffffffffffep-484,    0x1.fffffffffffffp-162},
+            {0x1.ffffffffffffep-481,    0x1.fffffffffffffp-161},
+            {0x1.ffffffffffffep-478,    0x1.fffffffffffffp-160},
+            {0x1.ffffffffffffep-475,    0x1.fffffffffffffp-159},
+            {0x1.ffffffffffffep-472,    0x1.fffffffffffffp-158},
+            {0x1.ffffffffffffep-469,    0x1.fffffffffffffp-157},
+            {0x1.ffffffffffffep-466,    0x1.fffffffffffffp-156},
+            {0x1.ffffffffffffep-463,    0x1.fffffffffffffp-155},
+            {0x1.ffffffffffffep-460,    0x1.fffffffffffffp-154},
+            {0x1.ffffffffffffep-457,    0x1.fffffffffffffp-153},
+            {0x1.ffffffffffffep-454,    0x1.fffffffffffffp-152},
+            {0x1.ffffffffffffep-451,    0x1.fffffffffffffp-151},
+            {0x1.ffffffffffffep-988,    0x1.fffffffffffffp-330},
+            {0x1.ffffffffffffep-448,    0x1.fffffffffffffp-150},
+            {0x1.ffffffffffffep-445,    0x1.fffffffffffffp-149},
+            {0x1.ffffffffffffep-442,    0x1.fffffffffffffp-148},
+            {0x1.ffffffffffffep-439,    0x1.fffffffffffffp-147},
+            {0x1.ffffffffffffep-436,    0x1.fffffffffffffp-146},
+            {0x1.ffffffffffffep-433,    0x1.fffffffffffffp-145},
+            {0x1.ffffffffffffep-430,    0x1.fffffffffffffp-144},
+            {0x1.ffffffffffffep-427,    0x1.fffffffffffffp-143},
+            {0x1.ffffffffffffep-424,    0x1.fffffffffffffp-142},
+            {0x1.ffffffffffffep-421,    0x1.fffffffffffffp-141},
+            {0x1.ffffffffffffep-418,    0x1.fffffffffffffp-140},
+            {0x1.ffffffffffffep-415,    0x1.fffffffffffffp-139},
+            {0x1.ffffffffffffep-412,    0x1.fffffffffffffp-138},
+            {0x1.ffffffffffffep-409,    0x1.fffffffffffffp-137},
+            {0x1.ffffffffffffep-406,    0x1.fffffffffffffp-136},
+            {0x1.ffffffffffffep-403,    0x1.fffffffffffffp-135},
+            {0x1.ffffffffffffep-985,    0x1.fffffffffffffp-329},
+            {0x1.ffffffffffffep-400,    0x1.fffffffffffffp-134},
+            {0x1.ffffffffffffep-397,    0x1.fffffffffffffp-133},
+            {0x1.ffffffffffffep-394,    0x1.fffffffffffffp-132},
+            {0x1.ffffffffffffep-391,    0x1.fffffffffffffp-131},
+            {0x1.ffffffffffffep-388,    0x1.fffffffffffffp-130},
+            {0x1.ffffffffffffep-385,    0x1.fffffffffffffp-129},
+            {0x1.ffffffffffffep-382,    0x1.fffffffffffffp-128},
+            {0x1.ffffffffffffep-379,    0x1.fffffffffffffp-127},
+            {0x1.ffffffffffffep-376,    0x1.fffffffffffffp-126},
+            {0x1.ffffffffffffep-373,    0x1.fffffffffffffp-125},
+            {0x1.ffffffffffffep-370,    0x1.fffffffffffffp-124},
+            {0x1.ffffffffffffep-367,    0x1.fffffffffffffp-123},
+            {0x1.ffffffffffffep-364,    0x1.fffffffffffffp-122},
+            {0x1.ffffffffffffep-361,    0x1.fffffffffffffp-121},
+            {0x1.ffffffffffffep-358,    0x1.fffffffffffffp-120},
+            {0x1.ffffffffffffep-355,    0x1.fffffffffffffp-119},
+            {0x1.ffffffffffffep-982,    0x1.fffffffffffffp-328},
+            {0x1.ffffffffffffep-352,    0x1.fffffffffffffp-118},
+            {0x1.ffffffffffffep-349,    0x1.fffffffffffffp-117},
+            {0x1.ffffffffffffep-346,    0x1.fffffffffffffp-116},
+            {0x1.ffffffffffffep-343,    0x1.fffffffffffffp-115},
+            {0x1.ffffffffffffep-340,    0x1.fffffffffffffp-114},
+            {0x1.ffffffffffffep-337,    0x1.fffffffffffffp-113},
+            {0x1.ffffffffffffep-334,    0x1.fffffffffffffp-112},
+            {0x1.ffffffffffffep-331,    0x1.fffffffffffffp-111},
+            {0x1.ffffffffffffep-328,    0x1.fffffffffffffp-110},
+            {0x1.ffffffffffffep-325,    0x1.fffffffffffffp-109},
+            {0x1.ffffffffffffep-322,    0x1.fffffffffffffp-108},
+            {0x1.ffffffffffffep-319,    0x1.fffffffffffffp-107},
+            {0x1.ffffffffffffep-316,    0x1.fffffffffffffp-106},
+            {0x1.ffffffffffffep-313,    0x1.fffffffffffffp-105},
+            {0x1.ffffffffffffep-310,    0x1.fffffffffffffp-104},
+            {0x1.ffffffffffffep-307,    0x1.fffffffffffffp-103},
+            {0x1.ffffffffffffep-979,    0x1.fffffffffffffp-327},
+            {0x1.ffffffffffffep-304,    0x1.fffffffffffffp-102},
+            {0x1.ffffffffffffep-301,    0x1.fffffffffffffp-101},
+            {0x1.ffffffffffffep-298,    0x1.fffffffffffffp-100},
+            {0x1.ffffffffffffep-295,    0x1.fffffffffffffp-99},
+            {0x1.ffffffffffffep-292,    0x1.fffffffffffffp-98},
+            {0x1.ffffffffffffep-289,    0x1.fffffffffffffp-97},
+            {0x1.ffffffffffffep-286,    0x1.fffffffffffffp-96},
+            {0x1.ffffffffffffep-283,    0x1.fffffffffffffp-95},
+            {0x1.ffffffffffffep-280,    0x1.fffffffffffffp-94},
+            {0x1.ffffffffffffep-277,    0x1.fffffffffffffp-93},
+            {0x1.ffffffffffffep-274,    0x1.fffffffffffffp-92},
+            {0x1.ffffffffffffep-271,    0x1.fffffffffffffp-91},
+            {0x1.ffffffffffffep-268,    0x1.fffffffffffffp-90},
+            {0x1.ffffffffffffep-265,    0x1.fffffffffffffp-89},
+            {0x1.ffffffffffffep-262,    0x1.fffffffffffffp-88},
+            {0x1.ffffffffffffep-259,    0x1.fffffffffffffp-87},
+            {0x1.ffffffffffffep-1021,   0x1.fffffffffffffp-341},
+            {0x1.ffffffffffffep-976,    0x1.fffffffffffffp-326},
+            {0x1.ffffffffffffep-256,    0x1.fffffffffffffp-86},
+            {0x1.ffffffffffffep-253,    0x1.fffffffffffffp-85},
+            {0x1.ffffffffffffep-250,    0x1.fffffffffffffp-84},
+            {0x1.ffffffffffffep-247,    0x1.fffffffffffffp-83},
+            {0x1.ffffffffffffep-244,    0x1.fffffffffffffp-82},
+            {0x1.ffffffffffffep-241,    0x1.fffffffffffffp-81},
+            {0x1.ffffffffffffep-238,    0x1.fffffffffffffp-80},
+            {0x1.ffffffffffffep-235,    0x1.fffffffffffffp-79},
+            {0x1.ffffffffffffep-232,    0x1.fffffffffffffp-78},
+            {0x1.ffffffffffffep-229,    0x1.fffffffffffffp-77},
+            {0x1.ffffffffffffep-226,    0x1.fffffffffffffp-76},
+            {0x1.ffffffffffffep-223,    0x1.fffffffffffffp-75},
+            {0x1.ffffffffffffep-220,    0x1.fffffffffffffp-74},
+            {0x1.ffffffffffffep-217,    0x1.fffffffffffffp-73},
+            {0x1.ffffffffffffep-214,    0x1.fffffffffffffp-72},
+            {0x1.ffffffffffffep-211,    0x1.fffffffffffffp-71},
+            {0x1.ffffffffffffep-973,    0x1.fffffffffffffp-325},
+            {0x1.ffffffffffffep-208,    0x1.fffffffffffffp-70},
+            {0x1.ffffffffffffep-205,    0x1.fffffffffffffp-69},
+            {0x1.ffffffffffffep-202,    0x1.fffffffffffffp-68},
+            {0x1.ffffffffffffep-199,    0x1.fffffffffffffp-67},
+            {0x1.ffffffffffffep-196,    0x1.fffffffffffffp-66},
+            {0x1.ffffffffffffep-193,    0x1.fffffffffffffp-65},
+            {0x1.ffffffffffffep-190,    0x1.fffffffffffffp-64},
+            {0x1.ffffffffffffep-187,    0x1.fffffffffffffp-63},
+            {0x1.ffffffffffffep-184,    0x1.fffffffffffffp-62},
+            {0x1.ffffffffffffep-181,    0x1.fffffffffffffp-61},
+            {0x1.ffffffffffffep-178,    0x1.fffffffffffffp-60},
+            {0x1.ffffffffffffep-175,    0x1.fffffffffffffp-59},
+            {0x1.ffffffffffffep-172,    0x1.fffffffffffffp-58},
+            {0x1.ffffffffffffep-169,    0x1.fffffffffffffp-57},
+            {0x1.ffffffffffffep-166,    0x1.fffffffffffffp-56},
+            {0x1.ffffffffffffep-163,    0x1.fffffffffffffp-55},
+            {0x1.ffffffffffffep-970,    0x1.fffffffffffffp-324},
+            {0x1.ffffffffffffep-160,    0x1.fffffffffffffp-54},
+            {0x1.ffffffffffffep-157,    0x1.fffffffffffffp-53},
+            {0x1.ffffffffffffep-154,    0x1.fffffffffffffp-52},
+            {0x1.ffffffffffffep-151,    0x1.fffffffffffffp-51},
+            {0x1.ffffffffffffep-148,    0x1.fffffffffffffp-50},
+            {0x1.ffffffffffffep-145,    0x1.fffffffffffffp-49},
+            {0x1.ffffffffffffep-142,    0x1.fffffffffffffp-48},
+            {0x1.ffffffffffffep-139,    0x1.fffffffffffffp-47},
+            {0x1.ffffffffffffep-136,    0x1.fffffffffffffp-46},
+            {0x1.ffffffffffffep-133,    0x1.fffffffffffffp-45},
+            {0x1.ffffffffffffep-130,    0x1.fffffffffffffp-44},
+            {0x1.ffffffffffffep-127,    0x1.fffffffffffffp-43},
+            {0x1.ffffffffffffep-124,    0x1.fffffffffffffp-42},
+            {0x1.ffffffffffffep-121,    0x1.fffffffffffffp-41},
+            {0x1.ffffffffffffep-118,    0x1.fffffffffffffp-40},
+            {0x1.ffffffffffffep-115,    0x1.fffffffffffffp-39},
+            {0x1.ffffffffffffep-967,    0x1.fffffffffffffp-323},
+            {0x1.ffffffffffffep-112,    0x1.fffffffffffffp-38},
+            {0x1.ffffffffffffep-109,    0x1.fffffffffffffp-37},
+            {0x1.ffffffffffffep-106,    0x1.fffffffffffffp-36},
+            {0x1.ffffffffffffep-103,    0x1.fffffffffffffp-35},
+            {0x1.ffffffffffffep-100,    0x1.fffffffffffffp-34},
+            {0x1.ffffffffffffep-97,     0x1.fffffffffffffp-33},
+            {0x1.ffffffffffffep-94,     0x1.fffffffffffffp-32},
+            {0x1.ffffffffffffep-91,     0x1.fffffffffffffp-31},
+            {0x1.ffffffffffffep-88,     0x1.fffffffffffffp-30},
+            {0x1.ffffffffffffep-85,     0x1.fffffffffffffp-29},
+            {0x1.ffffffffffffep-82,     0x1.fffffffffffffp-28},
+            {0x1.ffffffffffffep-79,     0x1.fffffffffffffp-27},
+            {0x1.ffffffffffffep-76,     0x1.fffffffffffffp-26},
+            {0x1.ffffffffffffep-73,     0x1.fffffffffffffp-25},
+            {0x1.ffffffffffffep-70,     0x1.fffffffffffffp-24},
+            {0x1.ffffffffffffep-67,     0x1.fffffffffffffp-23},
+            {0x1.ffffffffffffep-964,    0x1.fffffffffffffp-322},
+            {0x1.ffffffffffffep-64,     0x1.fffffffffffffp-22},
+            {0x1.ffffffffffffep-61,     0x1.fffffffffffffp-21},
+            {0x1.ffffffffffffep-58,     0x1.fffffffffffffp-20},
+            {0x1.ffffffffffffep-55,     0x1.fffffffffffffp-19},
+            {0x1.ffffffffffffep-52,     0x1.fffffffffffffp-18},
+            {0x1.ffffffffffffep-49,     0x1.fffffffffffffp-17},
+            {0x1.ffffffffffffep-46,     0x1.fffffffffffffp-16},
+            {0x1.ffffffffffffep-43,     0x1.fffffffffffffp-15},
+            {0x1.ffffffffffffep-40,     0x1.fffffffffffffp-14},
+            {0x1.ffffffffffffep-37,     0x1.fffffffffffffp-13},
+            {0x1.ffffffffffffep-34,     0x1.fffffffffffffp-12},
+            {0x1.ffffffffffffep-31,     0x1.fffffffffffffp-11},
+            {0x1.ffffffffffffep-28,     0x1.fffffffffffffp-10},
+            {0x1.ffffffffffffep-25,     0x1.fffffffffffffp-9},
+            {0x1.ffffffffffffep-22,     0x1.fffffffffffffp-8},
+            {0x0.000000000003ep-1022,   0x1.fa9c313858568p-357},
+            {0x1.ffffffffffffep-19,     0x1.fffffffffffffp-7},
+            {0x1.ffffffffffffep-961,    0x1.fffffffffffffp-321},
+            {0x1.ffffffffffffep-16,     0x1.fffffffffffffp-6},
+            {0x1.ffffffffffffep-13,     0x1.fffffffffffffp-5},
+            {0x1.ffffffffffffep-10,     0x1.fffffffffffffp-4},
+            {0x1.ffffffffffffep-7,      0x1.fffffffffffffp-3},
+            {0x0.000000000003fp-1022,   0x1.fd51bf2069fe6p-357},
+            {0x1.ffffffffffffep-4,      0x1.fffffffffffffp-2},
+            {0x1.ffffffffffffep-1,      0x1.fffffffffffffp-1},
+            {0x0.000000003fffcp-1022,   0x1.ffff55551c71bp-353},
+            {0x0.000003fffffe8p-1022,   0x1.ffffffcp-349},
+            {0x0.000003ffffffcp-1022,   0x1.fffffff555555p-349},
+            {0x0.003fffffffff9p-1022,   0x1.fffffffffed55p-345},
+            {0x1.ffffffffffffep2,       0x1.fffffffffffffp0},
+            {0x1.bp4,                   0x1.8p1},
+            {0x1.ffffffffffffep5,       0x1.fffffffffffffp1},
+            {0x1.f3ffffffffff4p6,       0x1.3fffffffffffep2},
+            {0x1.f3ffffffffffcp6,       0x1.3ffffffffffffp2},
+            {0x1.bp7,                   0x1.8p2},
+            {0x1.56ffffffffffep8,       0x1.bffffffffffffp2},
+            {0x1.ffffffffffffep8,       0x1.fffffffffffffp2},
+            {0x1.6c8p9,                 0x1.2p3},
+            {0x1.f3ffffffffff4p9,       0x1.3fffffffffffep3},
+            {0x1.f3ffffffffffcp9,       0x1.3ffffffffffffp3},
+            {0x1.4cbfffffffffcp10,      0x1.5fffffffffffep3},
+            {0x1.4cbfffffffffep10,      0x1.5ffffffffffffp3},
+            {0x1.bp10,                  0x1.8p3},
+            {0x1.129ffffffffa4p11,      0x1.9ffffffffffd1p3},
+            {0x1.129fffffffffep11,      0x1.9ffffffffffffp3},
+            {0x1.56ffffffffffep11,      0x1.bffffffffffffp3},
+            {0x1.a5ep11,                0x1.ep3},
+            {0x1.ffffffffffffep11,      0x1.fffffffffffffp3},
+            {0x1.330fffffffc1ep12,      0x1.0fffffffffedbp4},
+            {0x1.331p12,                0x1.1p4},
+            {0x1.6c8p12,                0x1.2p4},
+            {0x1.acafffffffffap12,      0x1.2ffffffffffffp4},
+            {0x1.acafffffffffep12,      0x1.2ffffffffffffp4},
+            {0x1.ffffffffffffep-958,    0x1.fffffffffffffp-320},
+            {0x1.ffffffffffffep-955,    0x1.fffffffffffffp-319},
+            {0x1.ffffffffffffep-952,    0x1.fffffffffffffp-318},
+            {0x1.ffffffffffffep-949,    0x1.fffffffffffffp-317},
+            {0x1.ffffffffffffep-946,    0x1.fffffffffffffp-316},
+            {0x1.ffffffffffffep-943,    0x1.fffffffffffffp-315},
+            {0x1.ffffffffffffep-940,    0x1.fffffffffffffp-314},
+            {0x1.ffffffffffffep-937,    0x1.fffffffffffffp-313},
+            {0x1.ffffffffffffep-934,    0x1.fffffffffffffp-312},
+            {0x1.ffffffffffffep-931,    0x1.fffffffffffffp-311},
+            {0x1.ffffffffffffep-1018,   0x1.fffffffffffffp-340},
+            {0x1.ffffffffffffep-928,    0x1.fffffffffffffp-310},
+            {0x1.ffffffffffffep-925,    0x1.fffffffffffffp-309},
+            {0x1.ffffffffffffep-922,    0x1.fffffffffffffp-308},
+            {0x1.ffffffffffffep-919,    0x1.fffffffffffffp-307},
+            {0x1.ffffffffffffep-916,    0x1.fffffffffffffp-306},
+            {0x1.ffffffffffffep-913,    0x1.fffffffffffffp-305},
+            {0x1.ffffffffffffep-910,    0x1.fffffffffffffp-304},
+            {0x1.ffffffffffffep-907,    0x1.fffffffffffffp-303},
+            {0x1.ffffffffffffep-904,    0x1.fffffffffffffp-302},
+            {0x0.0000000000007p-1022,   0x1.e9b5dba58189ep-358},
+            {0x1.ffffffffffffep-901,    0x1.fffffffffffffp-301},
+            {0x1.ffffffffffffep-898,    0x1.fffffffffffffp-300},
+            {0x0.0000000007ffp-1022,    0x1.ffeaa9c70ca31p-354},
+            {0x0.0000000007ffep-1022,   0x1.fffd5551c7149p-354},
+            {0x0.0000007fffffdp-1022,   0x1.ffffffcp-350},
+            {0x0.0000007fffffep-1022,   0x1.ffffffd555555p-350},
+            {0x0.0007ffffffffap-1022,   0x1.fffffffff8p-346},
+            {0x0.7ffffffffffffp-1022,   0x1.fffffffffffffp-342},
+            {0x1.ffffffffffffep-895,    0x1.fffffffffffffp-299},
+            {0x1.ffffffffffffep-892,    0x1.fffffffffffffp-298},
+            {0x1.ffffffffffffep-889,    0x1.fffffffffffffp-297},
+            {0x1.ffffffffffffep-886,    0x1.fffffffffffffp-296},
+            {0x1.ffffffffffffep-883,    0x1.fffffffffffffp-295},
+            {0x1.ffffffffffffep-1015,   0x1.fffffffffffffp-339},
+            {0x1.ffffffffffffep-880,    0x1.fffffffffffffp-294},
+            {0x1.ffffffffffffep-877,    0x1.fffffffffffffp-293},
+            {0x1.ffffffffffffep-874,    0x1.fffffffffffffp-292},
+            {0x1.ffffffffffffep-871,    0x1.fffffffffffffp-291},
+            {0x1.ffffffffffffep-868,    0x1.fffffffffffffp-290},
+            {0x1.ffffffffffffep-865,    0x1.fffffffffffffp-289},
+            {0x1.ffffffffffffep-862,    0x1.fffffffffffffp-288},
+            {0x1.ffffffffffffep-859,    0x1.fffffffffffffp-287},
+            {0x1.ffffffffffffep-856,    0x1.fffffffffffffp-286},