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