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