emul/src/main/java/java/lang/Math.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sun, 30 Sep 2012 18:29:37 -0700
branchemul
changeset 84 d65b3a2fbfaf
parent 67 cc0d42d2110a
child 104 1376481f15e7
permissions -rw-r--r--
Almost compilable
     1 /*
     2  * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    25 
    26 package java.lang;
    27 
    28 
    29 /**
    30  * The class {@code Math} contains methods for performing basic
    31  * numeric operations such as the elementary exponential, logarithm,
    32  * square root, and trigonometric functions.
    33  *
    34  * <p>Unlike some of the numeric methods of class
    35  * {@code StrictMath}, all implementations of the equivalent
    36  * functions of class {@code Math} are not defined to return the
    37  * bit-for-bit same results.  This relaxation permits
    38  * better-performing implementations where strict reproducibility is
    39  * not required.
    40  *
    41  * <p>By default many of the {@code Math} methods simply call
    42  * the equivalent method in {@code StrictMath} for their
    43  * implementation.  Code generators are encouraged to use
    44  * platform-specific native libraries or microprocessor instructions,
    45  * where available, to provide higher-performance implementations of
    46  * {@code Math} methods.  Such higher-performance
    47  * implementations still must conform to the specification for
    48  * {@code Math}.
    49  *
    50  * <p>The quality of implementation specifications concern two
    51  * properties, accuracy of the returned result and monotonicity of the
    52  * method.  Accuracy of the floating-point {@code Math} methods
    53  * is measured in terms of <i>ulps</i>, units in the last place.  For
    54  * a given floating-point format, an ulp of a specific real number
    55  * value is the distance between the two floating-point values
    56  * bracketing that numerical value.  When discussing the accuracy of a
    57  * method as a whole rather than at a specific argument, the number of
    58  * ulps cited is for the worst-case error at any argument.  If a
    59  * method always has an error less than 0.5 ulps, the method always
    60  * returns the floating-point number nearest the exact result; such a
    61  * method is <i>correctly rounded</i>.  A correctly rounded method is
    62  * generally the best a floating-point approximation can be; however,
    63  * it is impractical for many floating-point methods to be correctly
    64  * rounded.  Instead, for the {@code Math} class, a larger error
    65  * bound of 1 or 2 ulps is allowed for certain methods.  Informally,
    66  * with a 1 ulp error bound, when the exact result is a representable
    67  * number, the exact result should be returned as the computed result;
    68  * otherwise, either of the two floating-point values which bracket
    69  * the exact result may be returned.  For exact results large in
    70  * magnitude, one of the endpoints of the bracket may be infinite.
    71  * Besides accuracy at individual arguments, maintaining proper
    72  * relations between the method at different arguments is also
    73  * important.  Therefore, most methods with more than 0.5 ulp errors
    74  * are required to be <i>semi-monotonic</i>: whenever the mathematical
    75  * function is non-decreasing, so is the floating-point approximation,
    76  * likewise, whenever the mathematical function is non-increasing, so
    77  * is the floating-point approximation.  Not all approximations that
    78  * have 1 ulp accuracy will automatically meet the monotonicity
    79  * requirements.
    80  *
    81  * @author  unascribed
    82  * @author  Joseph D. Darcy
    83  * @since   JDK1.0
    84  */
    85 
    86 public final class Math {
    87 
    88     /**
    89      * Don't let anyone instantiate this class.
    90      */
    91     private Math() {}
    92 
    93     /**
    94      * The {@code double} value that is closer than any other to
    95      * <i>e</i>, the base of the natural logarithms.
    96      */
    97     public static final double E = 2.7182818284590452354;
    98 
    99     /**
   100      * The {@code double} value that is closer than any other to
   101      * <i>pi</i>, the ratio of the circumference of a circle to its
   102      * diameter.
   103      */
   104     public static final double PI = 3.14159265358979323846;
   105 
   106     /**
   107      * Returns the trigonometric sine of an angle.  Special cases:
   108      * <ul><li>If the argument is NaN or an infinity, then the
   109      * result is NaN.
   110      * <li>If the argument is zero, then the result is a zero with the
   111      * same sign as the argument.</ul>
   112      *
   113      * <p>The computed result must be within 1 ulp of the exact result.
   114      * Results must be semi-monotonic.
   115      *
   116      * @param   a   an angle, in radians.
   117      * @return  the sine of the argument.
   118      */
   119     public static double sin(double a) {
   120         return StrictMath.sin(a); // default impl. delegates to StrictMath
   121     }
   122 
   123     /**
   124      * Returns the trigonometric cosine of an angle. Special cases:
   125      * <ul><li>If the argument is NaN or an infinity, then the
   126      * result is NaN.</ul>
   127      *
   128      * <p>The computed result must be within 1 ulp of the exact result.
   129      * Results must be semi-monotonic.
   130      *
   131      * @param   a   an angle, in radians.
   132      * @return  the cosine of the argument.
   133      */
   134     public static double cos(double a) {
   135         return StrictMath.cos(a); // default impl. delegates to StrictMath
   136     }
   137 
   138     /**
   139      * Returns the trigonometric tangent of an angle.  Special cases:
   140      * <ul><li>If the argument is NaN or an infinity, then the result
   141      * is NaN.
   142      * <li>If the argument is zero, then the result is a zero with the
   143      * same sign as the argument.</ul>
   144      *
   145      * <p>The computed result must be within 1 ulp of the exact result.
   146      * Results must be semi-monotonic.
   147      *
   148      * @param   a   an angle, in radians.
   149      * @return  the tangent of the argument.
   150      */
   151     public static double tan(double a) {
   152         return StrictMath.tan(a); // default impl. delegates to StrictMath
   153     }
   154 
   155     /**
   156      * Returns the arc sine of a value; the returned angle is in the
   157      * range -<i>pi</i>/2 through <i>pi</i>/2.  Special cases:
   158      * <ul><li>If the argument is NaN or its absolute value is greater
   159      * than 1, then the result is NaN.
   160      * <li>If the argument is zero, then the result is a zero with the
   161      * same sign as the argument.</ul>
   162      *
   163      * <p>The computed result must be within 1 ulp of the exact result.
   164      * Results must be semi-monotonic.
   165      *
   166      * @param   a   the value whose arc sine is to be returned.
   167      * @return  the arc sine of the argument.
   168      */
   169     public static double asin(double a) {
   170         return StrictMath.asin(a); // default impl. delegates to StrictMath
   171     }
   172 
   173     /**
   174      * Returns the arc cosine of a value; the returned angle is in the
   175      * range 0.0 through <i>pi</i>.  Special case:
   176      * <ul><li>If the argument is NaN or its absolute value is greater
   177      * than 1, then the result is NaN.</ul>
   178      *
   179      * <p>The computed result must be within 1 ulp of the exact result.
   180      * Results must be semi-monotonic.
   181      *
   182      * @param   a   the value whose arc cosine is to be returned.
   183      * @return  the arc cosine of the argument.
   184      */
   185     public static double acos(double a) {
   186         return StrictMath.acos(a); // default impl. delegates to StrictMath
   187     }
   188 
   189     /**
   190      * Returns the arc tangent of a value; the returned angle is in the
   191      * range -<i>pi</i>/2 through <i>pi</i>/2.  Special cases:
   192      * <ul><li>If the argument is NaN, then the result is NaN.
   193      * <li>If the argument is zero, then the result is a zero with the
   194      * same sign as the argument.</ul>
   195      *
   196      * <p>The computed result must be within 1 ulp of the exact result.
   197      * Results must be semi-monotonic.
   198      *
   199      * @param   a   the value whose arc tangent is to be returned.
   200      * @return  the arc tangent of the argument.
   201      */
   202     public static double atan(double a) {
   203         return StrictMath.atan(a); // default impl. delegates to StrictMath
   204     }
   205 
   206     /**
   207      * Converts an angle measured in degrees to an approximately
   208      * equivalent angle measured in radians.  The conversion from
   209      * degrees to radians is generally inexact.
   210      *
   211      * @param   angdeg   an angle, in degrees
   212      * @return  the measurement of the angle {@code angdeg}
   213      *          in radians.
   214      * @since   1.2
   215      */
   216     public static double toRadians(double angdeg) {
   217         return angdeg / 180.0 * PI;
   218     }
   219 
   220     /**
   221      * Converts an angle measured in radians to an approximately
   222      * equivalent angle measured in degrees.  The conversion from
   223      * radians to degrees is generally inexact; users should
   224      * <i>not</i> expect {@code cos(toRadians(90.0))} to exactly
   225      * equal {@code 0.0}.
   226      *
   227      * @param   angrad   an angle, in radians
   228      * @return  the measurement of the angle {@code angrad}
   229      *          in degrees.
   230      * @since   1.2
   231      */
   232     public static double toDegrees(double angrad) {
   233         return angrad * 180.0 / PI;
   234     }
   235 
   236     /**
   237      * Returns Euler's number <i>e</i> raised to the power of a
   238      * {@code double} value.  Special cases:
   239      * <ul><li>If the argument is NaN, the result is NaN.
   240      * <li>If the argument is positive infinity, then the result is
   241      * positive infinity.
   242      * <li>If the argument is negative infinity, then the result is
   243      * positive zero.</ul>
   244      *
   245      * <p>The computed result must be within 1 ulp of the exact result.
   246      * Results must be semi-monotonic.
   247      *
   248      * @param   a   the exponent to raise <i>e</i> to.
   249      * @return  the value <i>e</i><sup>{@code a}</sup>,
   250      *          where <i>e</i> is the base of the natural logarithms.
   251      */
   252     public static double exp(double a) {
   253         return StrictMath.exp(a); // default impl. delegates to StrictMath
   254     }
   255 
   256     /**
   257      * Returns the natural logarithm (base <i>e</i>) of a {@code double}
   258      * value.  Special cases:
   259      * <ul><li>If the argument is NaN or less than zero, then the result
   260      * is NaN.
   261      * <li>If the argument is positive infinity, then the result is
   262      * positive infinity.
   263      * <li>If the argument is positive zero or negative zero, then the
   264      * result is negative infinity.</ul>
   265      *
   266      * <p>The computed result must be within 1 ulp of the exact result.
   267      * Results must be semi-monotonic.
   268      *
   269      * @param   a   a value
   270      * @return  the value ln&nbsp;{@code a}, the natural logarithm of
   271      *          {@code a}.
   272      */
   273     public static double log(double a) {
   274         return StrictMath.log(a); // default impl. delegates to StrictMath
   275     }
   276 
   277     /**
   278      * Returns the base 10 logarithm of a {@code double} value.
   279      * Special cases:
   280      *
   281      * <ul><li>If the argument is NaN or less than zero, then the result
   282      * is NaN.
   283      * <li>If the argument is positive infinity, then the result is
   284      * positive infinity.
   285      * <li>If the argument is positive zero or negative zero, then the
   286      * result is negative infinity.
   287      * <li> If the argument is equal to 10<sup><i>n</i></sup> for
   288      * integer <i>n</i>, then the result is <i>n</i>.
   289      * </ul>
   290      *
   291      * <p>The computed result must be within 1 ulp of the exact result.
   292      * Results must be semi-monotonic.
   293      *
   294      * @param   a   a value
   295      * @return  the base 10 logarithm of  {@code a}.
   296      * @since 1.5
   297      */
   298     public static double log10(double a) {
   299         return StrictMath.log10(a); // default impl. delegates to StrictMath
   300     }
   301 
   302     /**
   303      * Returns the correctly rounded positive square root of a
   304      * {@code double} value.
   305      * Special cases:
   306      * <ul><li>If the argument is NaN or less than zero, then the result
   307      * is NaN.
   308      * <li>If the argument is positive infinity, then the result is positive
   309      * infinity.
   310      * <li>If the argument is positive zero or negative zero, then the
   311      * result is the same as the argument.</ul>
   312      * Otherwise, the result is the {@code double} value closest to
   313      * the true mathematical square root of the argument value.
   314      *
   315      * @param   a   a value.
   316      * @return  the positive square root of {@code a}.
   317      *          If the argument is NaN or less than zero, the result is NaN.
   318      */
   319     public static double sqrt(double a) {
   320         return StrictMath.sqrt(a); // default impl. delegates to StrictMath
   321                                    // Note that hardware sqrt instructions
   322                                    // frequently can be directly used by JITs
   323                                    // and should be much faster than doing
   324                                    // Math.sqrt in software.
   325     }
   326 
   327 
   328     /**
   329      * Returns the cube root of a {@code double} value.  For
   330      * positive finite {@code x}, {@code cbrt(-x) ==
   331      * -cbrt(x)}; that is, the cube root of a negative value is
   332      * the negative of the cube root of that value's magnitude.
   333      *
   334      * Special cases:
   335      *
   336      * <ul>
   337      *
   338      * <li>If the argument is NaN, then the result is NaN.
   339      *
   340      * <li>If the argument is infinite, then the result is an infinity
   341      * with the same sign as the argument.
   342      *
   343      * <li>If the argument is zero, then the result is a zero with the
   344      * same sign as the argument.
   345      *
   346      * </ul>
   347      *
   348      * <p>The computed result must be within 1 ulp of the exact result.
   349      *
   350      * @param   a   a value.
   351      * @return  the cube root of {@code a}.
   352      * @since 1.5
   353      */
   354     public static double cbrt(double a) {
   355         return StrictMath.cbrt(a);
   356     }
   357 
   358     /**
   359      * Computes the remainder operation on two arguments as prescribed
   360      * by the IEEE 754 standard.
   361      * The remainder value is mathematically equal to
   362      * <code>f1&nbsp;-&nbsp;f2</code>&nbsp;&times;&nbsp;<i>n</i>,
   363      * where <i>n</i> is the mathematical integer closest to the exact
   364      * mathematical value of the quotient {@code f1/f2}, and if two
   365      * mathematical integers are equally close to {@code f1/f2},
   366      * then <i>n</i> is the integer that is even. If the remainder is
   367      * zero, its sign is the same as the sign of the first argument.
   368      * Special cases:
   369      * <ul><li>If either argument is NaN, or the first argument is infinite,
   370      * or the second argument is positive zero or negative zero, then the
   371      * result is NaN.
   372      * <li>If the first argument is finite and the second argument is
   373      * infinite, then the result is the same as the first argument.</ul>
   374      *
   375      * @param   f1   the dividend.
   376      * @param   f2   the divisor.
   377      * @return  the remainder when {@code f1} is divided by
   378      *          {@code f2}.
   379      */
   380     public static double IEEEremainder(double f1, double f2) {
   381         return StrictMath.IEEEremainder(f1, f2); // delegate to StrictMath
   382     }
   383 
   384     /**
   385      * Returns the smallest (closest to negative infinity)
   386      * {@code double} value that is greater than or equal to the
   387      * argument and is equal to a mathematical integer. Special cases:
   388      * <ul><li>If the argument value is already equal to a
   389      * mathematical integer, then the result is the same as the
   390      * argument.  <li>If the argument is NaN or an infinity or
   391      * positive zero or negative zero, then the result is the same as
   392      * the argument.  <li>If the argument value is less than zero but
   393      * greater than -1.0, then the result is negative zero.</ul> Note
   394      * that the value of {@code Math.ceil(x)} is exactly the
   395      * value of {@code -Math.floor(-x)}.
   396      *
   397      *
   398      * @param   a   a value.
   399      * @return  the smallest (closest to negative infinity)
   400      *          floating-point value that is greater than or equal to
   401      *          the argument and is equal to a mathematical integer.
   402      */
   403     public static double ceil(double a) {
   404         return StrictMath.ceil(a); // default impl. delegates to StrictMath
   405     }
   406 
   407     /**
   408      * Returns the largest (closest to positive infinity)
   409      * {@code double} value that is less than or equal to the
   410      * argument and is equal to a mathematical integer. Special cases:
   411      * <ul><li>If the argument value is already equal to a
   412      * mathematical integer, then the result is the same as the
   413      * argument.  <li>If the argument is NaN or an infinity or
   414      * positive zero or negative zero, then the result is the same as
   415      * the argument.</ul>
   416      *
   417      * @param   a   a value.
   418      * @return  the largest (closest to positive infinity)
   419      *          floating-point value that less than or equal to the argument
   420      *          and is equal to a mathematical integer.
   421      */
   422     public static double floor(double a) {
   423         return StrictMath.floor(a); // default impl. delegates to StrictMath
   424     }
   425 
   426     /**
   427      * Returns the {@code double} value that is closest in value
   428      * to the argument and is equal to a mathematical integer. If two
   429      * {@code double} values that are mathematical integers are
   430      * equally close, the result is the integer value that is
   431      * even. Special cases:
   432      * <ul><li>If the argument value is already equal to a mathematical
   433      * integer, then the result is the same as the argument.
   434      * <li>If the argument is NaN or an infinity or positive zero or negative
   435      * zero, then the result is the same as the argument.</ul>
   436      *
   437      * @param   a   a {@code double} value.
   438      * @return  the closest floating-point value to {@code a} that is
   439      *          equal to a mathematical integer.
   440      */
   441     public static double rint(double a) {
   442         return StrictMath.rint(a); // default impl. delegates to StrictMath
   443     }
   444 
   445     /**
   446      * Returns the angle <i>theta</i> from the conversion of rectangular
   447      * coordinates ({@code x},&nbsp;{@code y}) to polar
   448      * coordinates (r,&nbsp;<i>theta</i>).
   449      * This method computes the phase <i>theta</i> by computing an arc tangent
   450      * of {@code y/x} in the range of -<i>pi</i> to <i>pi</i>. Special
   451      * cases:
   452      * <ul><li>If either argument is NaN, then the result is NaN.
   453      * <li>If the first argument is positive zero and the second argument
   454      * is positive, or the first argument is positive and finite and the
   455      * second argument is positive infinity, then the result is positive
   456      * zero.
   457      * <li>If the first argument is negative zero and the second argument
   458      * is positive, or the first argument is negative and finite and the
   459      * second argument is positive infinity, then the result is negative zero.
   460      * <li>If the first argument is positive zero and the second argument
   461      * is negative, or the first argument is positive and finite and the
   462      * second argument is negative infinity, then the result is the
   463      * {@code double} value closest to <i>pi</i>.
   464      * <li>If the first argument is negative zero and the second argument
   465      * is negative, or the first argument is negative and finite and the
   466      * second argument is negative infinity, then the result is the
   467      * {@code double} value closest to -<i>pi</i>.
   468      * <li>If the first argument is positive and the second argument is
   469      * positive zero or negative zero, or the first argument is positive
   470      * infinity and the second argument is finite, then the result is the
   471      * {@code double} value closest to <i>pi</i>/2.
   472      * <li>If the first argument is negative and the second argument is
   473      * positive zero or negative zero, or the first argument is negative
   474      * infinity and the second argument is finite, then the result is the
   475      * {@code double} value closest to -<i>pi</i>/2.
   476      * <li>If both arguments are positive infinity, then the result is the
   477      * {@code double} value closest to <i>pi</i>/4.
   478      * <li>If the first argument is positive infinity and the second argument
   479      * is negative infinity, then the result is the {@code double}
   480      * value closest to 3*<i>pi</i>/4.
   481      * <li>If the first argument is negative infinity and the second argument
   482      * is positive infinity, then the result is the {@code double} value
   483      * closest to -<i>pi</i>/4.
   484      * <li>If both arguments are negative infinity, then the result is the
   485      * {@code double} value closest to -3*<i>pi</i>/4.</ul>
   486      *
   487      * <p>The computed result must be within 2 ulps of the exact result.
   488      * Results must be semi-monotonic.
   489      *
   490      * @param   y   the ordinate coordinate
   491      * @param   x   the abscissa coordinate
   492      * @return  the <i>theta</i> component of the point
   493      *          (<i>r</i>,&nbsp;<i>theta</i>)
   494      *          in polar coordinates that corresponds to the point
   495      *          (<i>x</i>,&nbsp;<i>y</i>) in Cartesian coordinates.
   496      */
   497     public static double atan2(double y, double x) {
   498         return StrictMath.atan2(y, x); // default impl. delegates to StrictMath
   499     }
   500 
   501     /**
   502      * Returns the value of the first argument raised to the power of the
   503      * second argument. Special cases:
   504      *
   505      * <ul><li>If the second argument is positive or negative zero, then the
   506      * result is 1.0.
   507      * <li>If the second argument is 1.0, then the result is the same as the
   508      * first argument.
   509      * <li>If the second argument is NaN, then the result is NaN.
   510      * <li>If the first argument is NaN and the second argument is nonzero,
   511      * then the result is NaN.
   512      *
   513      * <li>If
   514      * <ul>
   515      * <li>the absolute value of the first argument is greater than 1
   516      * and the second argument is positive infinity, or
   517      * <li>the absolute value of the first argument is less than 1 and
   518      * the second argument is negative infinity,
   519      * </ul>
   520      * then the result is positive infinity.
   521      *
   522      * <li>If
   523      * <ul>
   524      * <li>the absolute value of the first argument is greater than 1 and
   525      * the second argument is negative infinity, or
   526      * <li>the absolute value of the
   527      * first argument is less than 1 and the second argument is positive
   528      * infinity,
   529      * </ul>
   530      * then the result is positive zero.
   531      *
   532      * <li>If the absolute value of the first argument equals 1 and the
   533      * second argument is infinite, then the result is NaN.
   534      *
   535      * <li>If
   536      * <ul>
   537      * <li>the first argument is positive zero and the second argument
   538      * is greater than zero, or
   539      * <li>the first argument is positive infinity and the second
   540      * argument is less than zero,
   541      * </ul>
   542      * then the result is positive zero.
   543      *
   544      * <li>If
   545      * <ul>
   546      * <li>the first argument is positive zero and the second argument
   547      * is less than zero, or
   548      * <li>the first argument is positive infinity and the second
   549      * argument is greater than zero,
   550      * </ul>
   551      * then the result is positive infinity.
   552      *
   553      * <li>If
   554      * <ul>
   555      * <li>the first argument is negative zero and the second argument
   556      * is greater than zero but not a finite odd integer, or
   557      * <li>the first argument is negative infinity and the second
   558      * argument is less than zero but not a finite odd integer,
   559      * </ul>
   560      * then the result is positive zero.
   561      *
   562      * <li>If
   563      * <ul>
   564      * <li>the first argument is negative zero and the second argument
   565      * is a positive finite odd integer, or
   566      * <li>the first argument is negative infinity and the second
   567      * argument is a negative finite odd integer,
   568      * </ul>
   569      * then the result is negative zero.
   570      *
   571      * <li>If
   572      * <ul>
   573      * <li>the first argument is negative zero and the second argument
   574      * is less than zero but not a finite odd integer, or
   575      * <li>the first argument is negative infinity and the second
   576      * argument is greater than zero but not a finite odd integer,
   577      * </ul>
   578      * then the result is positive infinity.
   579      *
   580      * <li>If
   581      * <ul>
   582      * <li>the first argument is negative zero and the second argument
   583      * is a negative finite odd integer, or
   584      * <li>the first argument is negative infinity and the second
   585      * argument is a positive finite odd integer,
   586      * </ul>
   587      * then the result is negative infinity.
   588      *
   589      * <li>If the first argument is finite and less than zero
   590      * <ul>
   591      * <li> if the second argument is a finite even integer, the
   592      * result is equal to the result of raising the absolute value of
   593      * the first argument to the power of the second argument
   594      *
   595      * <li>if the second argument is a finite odd integer, the result
   596      * is equal to the negative of the result of raising the absolute
   597      * value of the first argument to the power of the second
   598      * argument
   599      *
   600      * <li>if the second argument is finite and not an integer, then
   601      * the result is NaN.
   602      * </ul>
   603      *
   604      * <li>If both arguments are integers, then the result is exactly equal
   605      * to the mathematical result of raising the first argument to the power
   606      * of the second argument if that result can in fact be represented
   607      * exactly as a {@code double} value.</ul>
   608      *
   609      * <p>(In the foregoing descriptions, a floating-point value is
   610      * considered to be an integer if and only if it is finite and a
   611      * fixed point of the method {@link #ceil ceil} or,
   612      * equivalently, a fixed point of the method {@link #floor
   613      * floor}. A value is a fixed point of a one-argument
   614      * method if and only if the result of applying the method to the
   615      * value is equal to the value.)
   616      *
   617      * <p>The computed result must be within 1 ulp of the exact result.
   618      * Results must be semi-monotonic.
   619      *
   620      * @param   a   the base.
   621      * @param   b   the exponent.
   622      * @return  the value {@code a}<sup>{@code b}</sup>.
   623      */
   624     public static double pow(double a, double b) {
   625         return StrictMath.pow(a, b); // default impl. delegates to StrictMath
   626     }
   627 
   628     /**
   629      * Returns the closest {@code int} to the argument, with ties
   630      * rounding up.
   631      *
   632      * <p>
   633      * Special cases:
   634      * <ul><li>If the argument is NaN, the result is 0.
   635      * <li>If the argument is negative infinity or any value less than or
   636      * equal to the value of {@code Integer.MIN_VALUE}, the result is
   637      * equal to the value of {@code Integer.MIN_VALUE}.
   638      * <li>If the argument is positive infinity or any value greater than or
   639      * equal to the value of {@code Integer.MAX_VALUE}, the result is
   640      * equal to the value of {@code Integer.MAX_VALUE}.</ul>
   641      *
   642      * @param   a   a floating-point value to be rounded to an integer.
   643      * @return  the value of the argument rounded to the nearest
   644      *          {@code int} value.
   645      * @see     java.lang.Integer#MAX_VALUE
   646      * @see     java.lang.Integer#MIN_VALUE
   647      */
   648     public static int round(float a) {
   649         if (a != 0x1.fffffep-2f) // greatest float value less than 0.5
   650             return (int)floor(a + 0.5f);
   651         else
   652             return 0;
   653     }
   654 
   655     /**
   656      * Returns the closest {@code long} to the argument, with ties
   657      * rounding up.
   658      *
   659      * <p>Special cases:
   660      * <ul><li>If the argument is NaN, the result is 0.
   661      * <li>If the argument is negative infinity or any value less than or
   662      * equal to the value of {@code Long.MIN_VALUE}, the result is
   663      * equal to the value of {@code Long.MIN_VALUE}.
   664      * <li>If the argument is positive infinity or any value greater than or
   665      * equal to the value of {@code Long.MAX_VALUE}, the result is
   666      * equal to the value of {@code Long.MAX_VALUE}.</ul>
   667      *
   668      * @param   a   a floating-point value to be rounded to a
   669      *          {@code long}.
   670      * @return  the value of the argument rounded to the nearest
   671      *          {@code long} value.
   672      * @see     java.lang.Long#MAX_VALUE
   673      * @see     java.lang.Long#MIN_VALUE
   674      */
   675     public static long round(double a) {
   676         if (a != 0x1.fffffffffffffp-2) // greatest double value less than 0.5
   677             return (long)floor(a + 0.5d);
   678         else
   679             return 0;
   680     }
   681 
   682 //    private static Random randomNumberGenerator;
   683 //
   684 //    private static synchronized Random initRNG() {
   685 //        Random rnd = randomNumberGenerator;
   686 //        return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd;
   687 //    }
   688 
   689     /**
   690      * Returns a {@code double} value with a positive sign, greater
   691      * than or equal to {@code 0.0} and less than {@code 1.0}.
   692      * Returned values are chosen pseudorandomly with (approximately)
   693      * uniform distribution from that range.
   694      *
   695      * <p>When this method is first called, it creates a single new
   696      * pseudorandom-number generator, exactly as if by the expression
   697      *
   698      * <blockquote>{@code new java.util.Random()}</blockquote>
   699      *
   700      * This new pseudorandom-number generator is used thereafter for
   701      * all calls to this method and is used nowhere else.
   702      *
   703      * <p>This method is properly synchronized to allow correct use by
   704      * more than one thread. However, if many threads need to generate
   705      * pseudorandom numbers at a great rate, it may reduce contention
   706      * for each thread to have its own pseudorandom-number generator.
   707      *
   708      * @return  a pseudorandom {@code double} greater than or equal
   709      * to {@code 0.0} and less than {@code 1.0}.
   710      * @see Random#nextDouble()
   711      */
   712     public static double random() {
   713         throw new UnsupportedOperationException();
   714     }
   715 
   716     /**
   717      * Returns the absolute value of an {@code int} value.
   718      * If the argument is not negative, the argument is returned.
   719      * If the argument is negative, the negation of the argument is returned.
   720      *
   721      * <p>Note that if the argument is equal to the value of
   722      * {@link Integer#MIN_VALUE}, the most negative representable
   723      * {@code int} value, the result is that same value, which is
   724      * negative.
   725      *
   726      * @param   a   the argument whose absolute value is to be determined
   727      * @return  the absolute value of the argument.
   728      */
   729     public static int abs(int a) {
   730         return (a < 0) ? -a : a;
   731     }
   732 
   733     /**
   734      * Returns the absolute value of a {@code long} value.
   735      * If the argument is not negative, the argument is returned.
   736      * If the argument is negative, the negation of the argument is returned.
   737      *
   738      * <p>Note that if the argument is equal to the value of
   739      * {@link Long#MIN_VALUE}, the most negative representable
   740      * {@code long} value, the result is that same value, which
   741      * is negative.
   742      *
   743      * @param   a   the argument whose absolute value is to be determined
   744      * @return  the absolute value of the argument.
   745      */
   746     public static long abs(long a) {
   747         return (a < 0) ? -a : a;
   748     }
   749 
   750     /**
   751      * Returns the absolute value of a {@code float} value.
   752      * If the argument is not negative, the argument is returned.
   753      * If the argument is negative, the negation of the argument is returned.
   754      * Special cases:
   755      * <ul><li>If the argument is positive zero or negative zero, the
   756      * result is positive zero.
   757      * <li>If the argument is infinite, the result is positive infinity.
   758      * <li>If the argument is NaN, the result is NaN.</ul>
   759      * In other words, the result is the same as the value of the expression:
   760      * <p>{@code Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))}
   761      *
   762      * @param   a   the argument whose absolute value is to be determined
   763      * @return  the absolute value of the argument.
   764      */
   765     public static float abs(float a) {
   766         return (a <= 0.0F) ? 0.0F - a : a;
   767     }
   768 
   769     /**
   770      * Returns the absolute value of a {@code double} value.
   771      * If the argument is not negative, the argument is returned.
   772      * If the argument is negative, the negation of the argument is returned.
   773      * Special cases:
   774      * <ul><li>If the argument is positive zero or negative zero, the result
   775      * is positive zero.
   776      * <li>If the argument is infinite, the result is positive infinity.
   777      * <li>If the argument is NaN, the result is NaN.</ul>
   778      * In other words, the result is the same as the value of the expression:
   779      * <p>{@code Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)}
   780      *
   781      * @param   a   the argument whose absolute value is to be determined
   782      * @return  the absolute value of the argument.
   783      */
   784     public static double abs(double a) {
   785         return (a <= 0.0D) ? 0.0D - a : a;
   786     }
   787 
   788     /**
   789      * Returns the greater of two {@code int} values. That is, the
   790      * result is the argument closer to the value of
   791      * {@link Integer#MAX_VALUE}. If the arguments have the same value,
   792      * the result is that same value.
   793      *
   794      * @param   a   an argument.
   795      * @param   b   another argument.
   796      * @return  the larger of {@code a} and {@code b}.
   797      */
   798     public static int max(int a, int b) {
   799         return (a >= b) ? a : b;
   800     }
   801 
   802     /**
   803      * Returns the greater of two {@code long} values. That is, the
   804      * result is the argument closer to the value of
   805      * {@link Long#MAX_VALUE}. If the arguments have the same value,
   806      * the result is that same value.
   807      *
   808      * @param   a   an argument.
   809      * @param   b   another argument.
   810      * @return  the larger of {@code a} and {@code b}.
   811      */
   812     public static long max(long a, long b) {
   813         return (a >= b) ? a : b;
   814     }
   815 
   816     private static long negativeZeroFloatBits = Float.floatToIntBits(-0.0f);
   817     private static long negativeZeroDoubleBits = Double.doubleToLongBits(-0.0d);
   818 
   819     /**
   820      * Returns the greater of two {@code float} values.  That is,
   821      * the result is the argument closer to positive infinity. If the
   822      * arguments have the same value, the result is that same
   823      * value. If either value is NaN, then the result is NaN.  Unlike
   824      * the numerical comparison operators, this method considers
   825      * negative zero to be strictly smaller than positive zero. If one
   826      * argument is positive zero and the other negative zero, the
   827      * result is positive zero.
   828      *
   829      * @param   a   an argument.
   830      * @param   b   another argument.
   831      * @return  the larger of {@code a} and {@code b}.
   832      */
   833     public static float max(float a, float b) {
   834         if (a != a) return a;   // a is NaN
   835         if ((a == 0.0f) && (b == 0.0f)
   836             && (Float.floatToIntBits(a) == negativeZeroFloatBits)) {
   837             return b;
   838         }
   839         return (a >= b) ? a : b;
   840     }
   841 
   842     /**
   843      * Returns the greater of two {@code double} values.  That
   844      * is, the result is the argument closer to positive infinity. If
   845      * the arguments have the same value, the result is that same
   846      * value. If either value is NaN, then the result is NaN.  Unlike
   847      * the numerical comparison operators, this method considers
   848      * negative zero to be strictly smaller than positive zero. If one
   849      * argument is positive zero and the other negative zero, the
   850      * result is positive zero.
   851      *
   852      * @param   a   an argument.
   853      * @param   b   another argument.
   854      * @return  the larger of {@code a} and {@code b}.
   855      */
   856     public static double max(double a, double b) {
   857         if (a != a) return a;   // a is NaN
   858         if ((a == 0.0d) && (b == 0.0d)
   859             && (Double.doubleToLongBits(a) == negativeZeroDoubleBits)) {
   860             return b;
   861         }
   862         return (a >= b) ? a : b;
   863     }
   864 
   865     /**
   866      * Returns the smaller of two {@code int} values. That is,
   867      * the result the argument closer to the value of
   868      * {@link Integer#MIN_VALUE}.  If the arguments have the same
   869      * value, the result is that same value.
   870      *
   871      * @param   a   an argument.
   872      * @param   b   another argument.
   873      * @return  the smaller of {@code a} and {@code b}.
   874      */
   875     public static int min(int a, int b) {
   876         return (a <= b) ? a : b;
   877     }
   878 
   879     /**
   880      * Returns the smaller of two {@code long} values. That is,
   881      * the result is the argument closer to the value of
   882      * {@link Long#MIN_VALUE}. If the arguments have the same
   883      * value, the result is that same value.
   884      *
   885      * @param   a   an argument.
   886      * @param   b   another argument.
   887      * @return  the smaller of {@code a} and {@code b}.
   888      */
   889     public static long min(long a, long b) {
   890         return (a <= b) ? a : b;
   891     }
   892 
   893     /**
   894      * Returns the smaller of two {@code float} values.  That is,
   895      * the result is the value closer to negative infinity. If the
   896      * arguments have the same value, the result is that same
   897      * value. If either value is NaN, then the result is NaN.  Unlike
   898      * the numerical comparison operators, this method considers
   899      * negative zero to be strictly smaller than positive zero.  If
   900      * one argument is positive zero and the other is negative zero,
   901      * the result is negative zero.
   902      *
   903      * @param   a   an argument.
   904      * @param   b   another argument.
   905      * @return  the smaller of {@code a} and {@code b}.
   906      */
   907     public static float min(float a, float b) {
   908         if (a != a) return a;   // a is NaN
   909         if ((a == 0.0f) && (b == 0.0f)
   910             && (Float.floatToIntBits(b) == negativeZeroFloatBits)) {
   911             return b;
   912         }
   913         return (a <= b) ? a : b;
   914     }
   915 
   916     /**
   917      * Returns the smaller of two {@code double} values.  That
   918      * is, the result is the value closer to negative infinity. If the
   919      * arguments have the same value, the result is that same
   920      * value. If either value is NaN, then the result is NaN.  Unlike
   921      * the numerical comparison operators, this method considers
   922      * negative zero to be strictly smaller than positive zero. If one
   923      * argument is positive zero and the other is negative zero, the
   924      * result is negative zero.
   925      *
   926      * @param   a   an argument.
   927      * @param   b   another argument.
   928      * @return  the smaller of {@code a} and {@code b}.
   929      */
   930     public static double min(double a, double b) {
   931         if (a != a) return a;   // a is NaN
   932         if ((a == 0.0d) && (b == 0.0d)
   933             && (Double.doubleToLongBits(b) == negativeZeroDoubleBits)) {
   934             return b;
   935         }
   936         return (a <= b) ? a : b;
   937     }
   938 
   939     /**
   940      * Returns the size of an ulp of the argument.  An ulp of a
   941      * {@code double} value is the positive distance between this
   942      * floating-point value and the {@code double} value next
   943      * larger in magnitude.  Note that for non-NaN <i>x</i>,
   944      * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
   945      *
   946      * <p>Special Cases:
   947      * <ul>
   948      * <li> If the argument is NaN, then the result is NaN.
   949      * <li> If the argument is positive or negative infinity, then the
   950      * result is positive infinity.
   951      * <li> If the argument is positive or negative zero, then the result is
   952      * {@code Double.MIN_VALUE}.
   953      * <li> If the argument is &plusmn;{@code Double.MAX_VALUE}, then
   954      * the result is equal to 2<sup>971</sup>.
   955      * </ul>
   956      *
   957      * @param d the floating-point value whose ulp is to be returned
   958      * @return the size of an ulp of the argument
   959      * @author Joseph D. Darcy
   960      * @since 1.5
   961      */
   962 //    public static double ulp(double d) {
   963 //        return sun.misc.FpUtils.ulp(d);
   964 //    }
   965 
   966     /**
   967      * Returns the size of an ulp of the argument.  An ulp of a
   968      * {@code float} value is the positive distance between this
   969      * floating-point value and the {@code float} value next
   970      * larger in magnitude.  Note that for non-NaN <i>x</i>,
   971      * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
   972      *
   973      * <p>Special Cases:
   974      * <ul>
   975      * <li> If the argument is NaN, then the result is NaN.
   976      * <li> If the argument is positive or negative infinity, then the
   977      * result is positive infinity.
   978      * <li> If the argument is positive or negative zero, then the result is
   979      * {@code Float.MIN_VALUE}.
   980      * <li> If the argument is &plusmn;{@code Float.MAX_VALUE}, then
   981      * the result is equal to 2<sup>104</sup>.
   982      * </ul>
   983      *
   984      * @param f the floating-point value whose ulp is to be returned
   985      * @return the size of an ulp of the argument
   986      * @author Joseph D. Darcy
   987      * @since 1.5
   988      */
   989 //    public static float ulp(float f) {
   990 //        return sun.misc.FpUtils.ulp(f);
   991 //    }
   992 
   993     /**
   994      * Returns the signum function of the argument; zero if the argument
   995      * is zero, 1.0 if the argument is greater than zero, -1.0 if the
   996      * argument is less than zero.
   997      *
   998      * <p>Special Cases:
   999      * <ul>
  1000      * <li> If the argument is NaN, then the result is NaN.
  1001      * <li> If the argument is positive zero or negative zero, then the
  1002      *      result is the same as the argument.
  1003      * </ul>
  1004      *
  1005      * @param d the floating-point value whose signum is to be returned
  1006      * @return the signum function of the argument
  1007      * @author Joseph D. Darcy
  1008      * @since 1.5
  1009      */
  1010 //    public static double signum(double d) {
  1011 //        return sun.misc.FpUtils.signum(d);
  1012 //    }
  1013 
  1014     /**
  1015      * Returns the signum function of the argument; zero if the argument
  1016      * is zero, 1.0f if the argument is greater than zero, -1.0f if the
  1017      * argument is less than zero.
  1018      *
  1019      * <p>Special Cases:
  1020      * <ul>
  1021      * <li> If the argument is NaN, then the result is NaN.
  1022      * <li> If the argument is positive zero or negative zero, then the
  1023      *      result is the same as the argument.
  1024      * </ul>
  1025      *
  1026      * @param f the floating-point value whose signum is to be returned
  1027      * @return the signum function of the argument
  1028      * @author Joseph D. Darcy
  1029      * @since 1.5
  1030      */
  1031 //    public static float signum(float f) {
  1032 //        return sun.misc.FpUtils.signum(f);
  1033 //    }
  1034 
  1035     /**
  1036      * Returns the hyperbolic sine of a {@code double} value.
  1037      * The hyperbolic sine of <i>x</i> is defined to be
  1038      * (<i>e<sup>x</sup>&nbsp;-&nbsp;e<sup>-x</sup></i>)/2
  1039      * where <i>e</i> is {@linkplain Math#E Euler's number}.
  1040      *
  1041      * <p>Special cases:
  1042      * <ul>
  1043      *
  1044      * <li>If the argument is NaN, then the result is NaN.
  1045      *
  1046      * <li>If the argument is infinite, then the result is an infinity
  1047      * with the same sign as the argument.
  1048      *
  1049      * <li>If the argument is zero, then the result is a zero with the
  1050      * same sign as the argument.
  1051      *
  1052      * </ul>
  1053      *
  1054      * <p>The computed result must be within 2.5 ulps of the exact result.
  1055      *
  1056      * @param   x The number whose hyperbolic sine is to be returned.
  1057      * @return  The hyperbolic sine of {@code x}.
  1058      * @since 1.5
  1059      */
  1060     public static double sinh(double x) {
  1061         return StrictMath.sinh(x);
  1062     }
  1063 
  1064     /**
  1065      * Returns the hyperbolic cosine of a {@code double} value.
  1066      * The hyperbolic cosine of <i>x</i> is defined to be
  1067      * (<i>e<sup>x</sup>&nbsp;+&nbsp;e<sup>-x</sup></i>)/2
  1068      * where <i>e</i> is {@linkplain Math#E Euler's number}.
  1069      *
  1070      * <p>Special cases:
  1071      * <ul>
  1072      *
  1073      * <li>If the argument is NaN, then the result is NaN.
  1074      *
  1075      * <li>If the argument is infinite, then the result is positive
  1076      * infinity.
  1077      *
  1078      * <li>If the argument is zero, then the result is {@code 1.0}.
  1079      *
  1080      * </ul>
  1081      *
  1082      * <p>The computed result must be within 2.5 ulps of the exact result.
  1083      *
  1084      * @param   x The number whose hyperbolic cosine is to be returned.
  1085      * @return  The hyperbolic cosine of {@code x}.
  1086      * @since 1.5
  1087      */
  1088     public static double cosh(double x) {
  1089         return StrictMath.cosh(x);
  1090     }
  1091 
  1092     /**
  1093      * Returns the hyperbolic tangent of a {@code double} value.
  1094      * The hyperbolic tangent of <i>x</i> is defined to be
  1095      * (<i>e<sup>x</sup>&nbsp;-&nbsp;e<sup>-x</sup></i>)/(<i>e<sup>x</sup>&nbsp;+&nbsp;e<sup>-x</sup></i>),
  1096      * in other words, {@linkplain Math#sinh
  1097      * sinh(<i>x</i>)}/{@linkplain Math#cosh cosh(<i>x</i>)}.  Note
  1098      * that the absolute value of the exact tanh is always less than
  1099      * 1.
  1100      *
  1101      * <p>Special cases:
  1102      * <ul>
  1103      *
  1104      * <li>If the argument is NaN, then the result is NaN.
  1105      *
  1106      * <li>If the argument is zero, then the result is a zero with the
  1107      * same sign as the argument.
  1108      *
  1109      * <li>If the argument is positive infinity, then the result is
  1110      * {@code +1.0}.
  1111      *
  1112      * <li>If the argument is negative infinity, then the result is
  1113      * {@code -1.0}.
  1114      *
  1115      * </ul>
  1116      *
  1117      * <p>The computed result must be within 2.5 ulps of the exact result.
  1118      * The result of {@code tanh} for any finite input must have
  1119      * an absolute value less than or equal to 1.  Note that once the
  1120      * exact result of tanh is within 1/2 of an ulp of the limit value
  1121      * of &plusmn;1, correctly signed &plusmn;{@code 1.0} should
  1122      * be returned.
  1123      *
  1124      * @param   x The number whose hyperbolic tangent is to be returned.
  1125      * @return  The hyperbolic tangent of {@code x}.
  1126      * @since 1.5
  1127      */
  1128     public static double tanh(double x) {
  1129         return StrictMath.tanh(x);
  1130     }
  1131 
  1132     /**
  1133      * Returns sqrt(<i>x</i><sup>2</sup>&nbsp;+<i>y</i><sup>2</sup>)
  1134      * without intermediate overflow or underflow.
  1135      *
  1136      * <p>Special cases:
  1137      * <ul>
  1138      *
  1139      * <li> If either argument is infinite, then the result
  1140      * is positive infinity.
  1141      *
  1142      * <li> If either argument is NaN and neither argument is infinite,
  1143      * then the result is NaN.
  1144      *
  1145      * </ul>
  1146      *
  1147      * <p>The computed result must be within 1 ulp of the exact
  1148      * result.  If one parameter is held constant, the results must be
  1149      * semi-monotonic in the other parameter.
  1150      *
  1151      * @param x a value
  1152      * @param y a value
  1153      * @return sqrt(<i>x</i><sup>2</sup>&nbsp;+<i>y</i><sup>2</sup>)
  1154      * without intermediate overflow or underflow
  1155      * @since 1.5
  1156      */
  1157     public static double hypot(double x, double y) {
  1158         return StrictMath.hypot(x, y);
  1159     }
  1160 
  1161     /**
  1162      * Returns <i>e</i><sup>x</sup>&nbsp;-1.  Note that for values of
  1163      * <i>x</i> near 0, the exact sum of
  1164      * {@code expm1(x)}&nbsp;+&nbsp;1 is much closer to the true
  1165      * result of <i>e</i><sup>x</sup> than {@code exp(x)}.
  1166      *
  1167      * <p>Special cases:
  1168      * <ul>
  1169      * <li>If the argument is NaN, the result is NaN.
  1170      *
  1171      * <li>If the argument is positive infinity, then the result is
  1172      * positive infinity.
  1173      *
  1174      * <li>If the argument is negative infinity, then the result is
  1175      * -1.0.
  1176      *
  1177      * <li>If the argument is zero, then the result is a zero with the
  1178      * same sign as the argument.
  1179      *
  1180      * </ul>
  1181      *
  1182      * <p>The computed result must be within 1 ulp of the exact result.
  1183      * Results must be semi-monotonic.  The result of
  1184      * {@code expm1} for any finite input must be greater than or
  1185      * equal to {@code -1.0}.  Note that once the exact result of
  1186      * <i>e</i><sup>{@code x}</sup>&nbsp;-&nbsp;1 is within 1/2
  1187      * ulp of the limit value -1, {@code -1.0} should be
  1188      * returned.
  1189      *
  1190      * @param   x   the exponent to raise <i>e</i> to in the computation of
  1191      *              <i>e</i><sup>{@code x}</sup>&nbsp;-1.
  1192      * @return  the value <i>e</i><sup>{@code x}</sup>&nbsp;-&nbsp;1.
  1193      * @since 1.5
  1194      */
  1195     public static double expm1(double x) {
  1196         return StrictMath.expm1(x);
  1197     }
  1198 
  1199     /**
  1200      * Returns the natural logarithm of the sum of the argument and 1.
  1201      * Note that for small values {@code x}, the result of
  1202      * {@code log1p(x)} is much closer to the true result of ln(1
  1203      * + {@code x}) than the floating-point evaluation of
  1204      * {@code log(1.0+x)}.
  1205      *
  1206      * <p>Special cases:
  1207      *
  1208      * <ul>
  1209      *
  1210      * <li>If the argument is NaN or less than -1, then the result is
  1211      * NaN.
  1212      *
  1213      * <li>If the argument is positive infinity, then the result is
  1214      * positive infinity.
  1215      *
  1216      * <li>If the argument is negative one, then the result is
  1217      * negative infinity.
  1218      *
  1219      * <li>If the argument is zero, then the result is a zero with the
  1220      * same sign as the argument.
  1221      *
  1222      * </ul>
  1223      *
  1224      * <p>The computed result must be within 1 ulp of the exact result.
  1225      * Results must be semi-monotonic.
  1226      *
  1227      * @param   x   a value
  1228      * @return the value ln({@code x}&nbsp;+&nbsp;1), the natural
  1229      * log of {@code x}&nbsp;+&nbsp;1
  1230      * @since 1.5
  1231      */
  1232     public static double log1p(double x) {
  1233         return StrictMath.log1p(x);
  1234     }
  1235 
  1236     /**
  1237      * Returns the first floating-point argument with the sign of the
  1238      * second floating-point argument.  Note that unlike the {@link
  1239      * StrictMath#copySign(double, double) StrictMath.copySign}
  1240      * method, this method does not require NaN {@code sign}
  1241      * arguments to be treated as positive values; implementations are
  1242      * permitted to treat some NaN arguments as positive and other NaN
  1243      * arguments as negative to allow greater performance.
  1244      *
  1245      * @param magnitude  the parameter providing the magnitude of the result
  1246      * @param sign   the parameter providing the sign of the result
  1247      * @return a value with the magnitude of {@code magnitude}
  1248      * and the sign of {@code sign}.
  1249      * @since 1.6
  1250      */
  1251 //    public static double copySign(double magnitude, double sign) {
  1252 //        return sun.misc.FpUtils.rawCopySign(magnitude, sign);
  1253 //    }
  1254 
  1255     /**
  1256      * Returns the first floating-point argument with the sign of the
  1257      * second floating-point argument.  Note that unlike the {@link
  1258      * StrictMath#copySign(float, float) StrictMath.copySign}
  1259      * method, this method does not require NaN {@code sign}
  1260      * arguments to be treated as positive values; implementations are
  1261      * permitted to treat some NaN arguments as positive and other NaN
  1262      * arguments as negative to allow greater performance.
  1263      *
  1264      * @param magnitude  the parameter providing the magnitude of the result
  1265      * @param sign   the parameter providing the sign of the result
  1266      * @return a value with the magnitude of {@code magnitude}
  1267      * and the sign of {@code sign}.
  1268      * @since 1.6
  1269      */
  1270 //    public static float copySign(float magnitude, float sign) {
  1271 //        return sun.misc.FpUtils.rawCopySign(magnitude, sign);
  1272 //    }
  1273 
  1274     /**
  1275      * Returns the unbiased exponent used in the representation of a
  1276      * {@code float}.  Special cases:
  1277      *
  1278      * <ul>
  1279      * <li>If the argument is NaN or infinite, then the result is
  1280      * {@link Float#MAX_EXPONENT} + 1.
  1281      * <li>If the argument is zero or subnormal, then the result is
  1282      * {@link Float#MIN_EXPONENT} -1.
  1283      * </ul>
  1284      * @param f a {@code float} value
  1285      * @return the unbiased exponent of the argument
  1286      * @since 1.6
  1287      */
  1288 //    public static int getExponent(float f) {
  1289 //        return sun.misc.FpUtils.getExponent(f);
  1290 //    }
  1291 
  1292     /**
  1293      * Returns the unbiased exponent used in the representation of a
  1294      * {@code double}.  Special cases:
  1295      *
  1296      * <ul>
  1297      * <li>If the argument is NaN or infinite, then the result is
  1298      * {@link Double#MAX_EXPONENT} + 1.
  1299      * <li>If the argument is zero or subnormal, then the result is
  1300      * {@link Double#MIN_EXPONENT} -1.
  1301      * </ul>
  1302      * @param d a {@code double} value
  1303      * @return the unbiased exponent of the argument
  1304      * @since 1.6
  1305      */
  1306 //    public static int getExponent(double d) {
  1307 //        return sun.misc.FpUtils.getExponent(d);
  1308 //    }
  1309 
  1310     /**
  1311      * Returns the floating-point number adjacent to the first
  1312      * argument in the direction of the second argument.  If both
  1313      * arguments compare as equal the second argument is returned.
  1314      *
  1315      * <p>
  1316      * Special cases:
  1317      * <ul>
  1318      * <li> If either argument is a NaN, then NaN is returned.
  1319      *
  1320      * <li> If both arguments are signed zeros, {@code direction}
  1321      * is returned unchanged (as implied by the requirement of
  1322      * returning the second argument if the arguments compare as
  1323      * equal).
  1324      *
  1325      * <li> If {@code start} is
  1326      * &plusmn;{@link Double#MIN_VALUE} and {@code direction}
  1327      * has a value such that the result should have a smaller
  1328      * magnitude, then a zero with the same sign as {@code start}
  1329      * is returned.
  1330      *
  1331      * <li> If {@code start} is infinite and
  1332      * {@code direction} has a value such that the result should
  1333      * have a smaller magnitude, {@link Double#MAX_VALUE} with the
  1334      * same sign as {@code start} is returned.
  1335      *
  1336      * <li> If {@code start} is equal to &plusmn;
  1337      * {@link Double#MAX_VALUE} and {@code direction} has a
  1338      * value such that the result should have a larger magnitude, an
  1339      * infinity with same sign as {@code start} is returned.
  1340      * </ul>
  1341      *
  1342      * @param start  starting floating-point value
  1343      * @param direction value indicating which of
  1344      * {@code start}'s neighbors or {@code start} should
  1345      * be returned
  1346      * @return The floating-point number adjacent to {@code start} in the
  1347      * direction of {@code direction}.
  1348      * @since 1.6
  1349      */
  1350 //    public static double nextAfter(double start, double direction) {
  1351 //        return sun.misc.FpUtils.nextAfter(start, direction);
  1352 //    }
  1353 
  1354     /**
  1355      * Returns the floating-point number adjacent to the first
  1356      * argument in the direction of the second argument.  If both
  1357      * arguments compare as equal a value equivalent to the second argument
  1358      * is returned.
  1359      *
  1360      * <p>
  1361      * Special cases:
  1362      * <ul>
  1363      * <li> If either argument is a NaN, then NaN is returned.
  1364      *
  1365      * <li> If both arguments are signed zeros, a value equivalent
  1366      * to {@code direction} is returned.
  1367      *
  1368      * <li> If {@code start} is
  1369      * &plusmn;{@link Float#MIN_VALUE} and {@code direction}
  1370      * has a value such that the result should have a smaller
  1371      * magnitude, then a zero with the same sign as {@code start}
  1372      * is returned.
  1373      *
  1374      * <li> If {@code start} is infinite and
  1375      * {@code direction} has a value such that the result should
  1376      * have a smaller magnitude, {@link Float#MAX_VALUE} with the
  1377      * same sign as {@code start} is returned.
  1378      *
  1379      * <li> If {@code start} is equal to &plusmn;
  1380      * {@link Float#MAX_VALUE} and {@code direction} has a
  1381      * value such that the result should have a larger magnitude, an
  1382      * infinity with same sign as {@code start} is returned.
  1383      * </ul>
  1384      *
  1385      * @param start  starting floating-point value
  1386      * @param direction value indicating which of
  1387      * {@code start}'s neighbors or {@code start} should
  1388      * be returned
  1389      * @return The floating-point number adjacent to {@code start} in the
  1390      * direction of {@code direction}.
  1391      * @since 1.6
  1392      */
  1393 //    public static float nextAfter(float start, double direction) {
  1394 //        return sun.misc.FpUtils.nextAfter(start, direction);
  1395 //    }
  1396 
  1397     /**
  1398      * Returns the floating-point value adjacent to {@code d} in
  1399      * the direction of positive infinity.  This method is
  1400      * semantically equivalent to {@code nextAfter(d,
  1401      * Double.POSITIVE_INFINITY)}; however, a {@code nextUp}
  1402      * implementation may run faster than its equivalent
  1403      * {@code nextAfter} call.
  1404      *
  1405      * <p>Special Cases:
  1406      * <ul>
  1407      * <li> If the argument is NaN, the result is NaN.
  1408      *
  1409      * <li> If the argument is positive infinity, the result is
  1410      * positive infinity.
  1411      *
  1412      * <li> If the argument is zero, the result is
  1413      * {@link Double#MIN_VALUE}
  1414      *
  1415      * </ul>
  1416      *
  1417      * @param d starting floating-point value
  1418      * @return The adjacent floating-point value closer to positive
  1419      * infinity.
  1420      * @since 1.6
  1421      */
  1422 //    public static double nextUp(double d) {
  1423 //        return sun.misc.FpUtils.nextUp(d);
  1424 //    }
  1425 
  1426     /**
  1427      * Returns the floating-point value adjacent to {@code f} in
  1428      * the direction of positive infinity.  This method is
  1429      * semantically equivalent to {@code nextAfter(f,
  1430      * Float.POSITIVE_INFINITY)}; however, a {@code nextUp}
  1431      * implementation may run faster than its equivalent
  1432      * {@code nextAfter} call.
  1433      *
  1434      * <p>Special Cases:
  1435      * <ul>
  1436      * <li> If the argument is NaN, the result is NaN.
  1437      *
  1438      * <li> If the argument is positive infinity, the result is
  1439      * positive infinity.
  1440      *
  1441      * <li> If the argument is zero, the result is
  1442      * {@link Float#MIN_VALUE}
  1443      *
  1444      * </ul>
  1445      *
  1446      * @param f starting floating-point value
  1447      * @return The adjacent floating-point value closer to positive
  1448      * infinity.
  1449      * @since 1.6
  1450      */
  1451 //    public static float nextUp(float f) {
  1452 //        return sun.misc.FpUtils.nextUp(f);
  1453 //    }
  1454 
  1455 
  1456     /**
  1457      * Return {@code d} &times;
  1458      * 2<sup>{@code scaleFactor}</sup> rounded as if performed
  1459      * by a single correctly rounded floating-point multiply to a
  1460      * member of the double value set.  See the Java
  1461      * Language Specification for a discussion of floating-point
  1462      * value sets.  If the exponent of the result is between {@link
  1463      * Double#MIN_EXPONENT} and {@link Double#MAX_EXPONENT}, the
  1464      * answer is calculated exactly.  If the exponent of the result
  1465      * would be larger than {@code Double.MAX_EXPONENT}, an
  1466      * infinity is returned.  Note that if the result is subnormal,
  1467      * precision may be lost; that is, when {@code scalb(x, n)}
  1468      * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
  1469      * <i>x</i>.  When the result is non-NaN, the result has the same
  1470      * sign as {@code d}.
  1471      *
  1472      * <p>Special cases:
  1473      * <ul>
  1474      * <li> If the first argument is NaN, NaN is returned.
  1475      * <li> If the first argument is infinite, then an infinity of the
  1476      * same sign is returned.
  1477      * <li> If the first argument is zero, then a zero of the same
  1478      * sign is returned.
  1479      * </ul>
  1480      *
  1481      * @param d number to be scaled by a power of two.
  1482      * @param scaleFactor power of 2 used to scale {@code d}
  1483      * @return {@code d} &times; 2<sup>{@code scaleFactor}</sup>
  1484      * @since 1.6
  1485      */
  1486 //    public static double scalb(double d, int scaleFactor) {
  1487 //        return sun.misc.FpUtils.scalb(d, scaleFactor);
  1488 //    }
  1489 
  1490     /**
  1491      * Return {@code f} &times;
  1492      * 2<sup>{@code scaleFactor}</sup> rounded as if performed
  1493      * by a single correctly rounded floating-point multiply to a
  1494      * member of the float value set.  See the Java
  1495      * Language Specification for a discussion of floating-point
  1496      * value sets.  If the exponent of the result is between {@link
  1497      * Float#MIN_EXPONENT} and {@link Float#MAX_EXPONENT}, the
  1498      * answer is calculated exactly.  If the exponent of the result
  1499      * would be larger than {@code Float.MAX_EXPONENT}, an
  1500      * infinity is returned.  Note that if the result is subnormal,
  1501      * precision may be lost; that is, when {@code scalb(x, n)}
  1502      * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
  1503      * <i>x</i>.  When the result is non-NaN, the result has the same
  1504      * sign as {@code f}.
  1505      *
  1506      * <p>Special cases:
  1507      * <ul>
  1508      * <li> If the first argument is NaN, NaN is returned.
  1509      * <li> If the first argument is infinite, then an infinity of the
  1510      * same sign is returned.
  1511      * <li> If the first argument is zero, then a zero of the same
  1512      * sign is returned.
  1513      * </ul>
  1514      *
  1515      * @param f number to be scaled by a power of two.
  1516      * @param scaleFactor power of 2 used to scale {@code f}
  1517      * @return {@code f} &times; 2<sup>{@code scaleFactor}</sup>
  1518      * @since 1.6
  1519      */
  1520 //    public static float scalb(float f, int scaleFactor) {
  1521 //        return sun.misc.FpUtils.scalb(f, scaleFactor);
  1522 //    }
  1523 }