1 /*
   2  * Copyright (c) 1999, 2019, 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 java.util.Random;
  29 import jdk.internal.math.DoubleConsts;
  30 import jdk.internal.HotSpotIntrinsicCandidate;
  31 
  32 /**
  33  * The class {@code StrictMath} contains methods for performing basic
  34  * numeric operations such as the elementary exponential, logarithm,
  35  * square root, and trigonometric functions.
  36  *
  37  * <p>To help ensure portability of Java programs, the definitions of
  38  * some of the numeric functions in this package require that they
  39  * produce the same results as certain published algorithms. These
  40  * algorithms are available from the well-known network library
  41  * {@code netlib} as the package "Freely Distributable Math
  42  * Library," <a
  43  * href="https://www.netlib.org/fdlibm/">{@code fdlibm}</a>. These
  44  * algorithms, which are written in the C programming language, are
  45  * then to be understood as executed with all floating-point
  46  * operations following the rules of Java floating-point arithmetic.
  47  *
  48  * <p>The Java math library is defined with respect to
  49  * {@code fdlibm} version 5.3. Where {@code fdlibm} provides
  50  * more than one definition for a function (such as
  51  * {@code acos}), use the "IEEE 754 core function" version
  52  * (residing in a file whose name begins with the letter
  53  * {@code e}).  The methods which require {@code fdlibm}
  54  * semantics are {@code sin}, {@code cos}, {@code tan},
  55  * {@code asin}, {@code acos}, {@code atan},
  56  * {@code exp}, {@code log}, {@code log10},
  57  * {@code cbrt}, {@code atan2}, {@code pow},
  58  * {@code sinh}, {@code cosh}, {@code tanh},
  59  * {@code hypot}, {@code expm1}, and {@code log1p}.
  60  *
  61  * <p>
  62  * The platform uses signed two's complement integer arithmetic with
  63  * int and long primitive types.  The developer should choose
  64  * the primitive type to ensure that arithmetic operations consistently
  65  * produce correct results, which in some cases means the operations
  66  * will not overflow the range of values of the computation.
  67  * The best practice is to choose the primitive type and algorithm to avoid
  68  * overflow. In cases where the size is {@code int} or {@code long} and
  69  * overflow errors need to be detected, the methods {@code addExact},
  70  * {@code subtractExact}, {@code multiplyExact}, {@code toIntExact},
  71  * {@code incrementExact}, {@code decrementExact} and {@code negateExact}
  72  * throw an {@code ArithmeticException} when the results overflow.
  73  * For the arithmetic operations divide and absolute value, overflow
  74  * occurs only with a specific minimum or maximum value and
  75  * should be checked against the minimum or maximum as appropriate.

  76  *
  77  * @author  unascribed
  78  * @author  Joseph D. Darcy
  79  * @since   1.3
  80  */
  81 
  82 public final class StrictMath {
  83 
  84     /**
  85      * Don't let anyone instantiate this class.
  86      */
  87     private StrictMath() {}
  88 
  89     /**
  90      * The {@code double} value that is closer than any other to
  91      * <i>e</i>, the base of the natural logarithms.
  92      */
  93     public static final double E = 2.7182818284590452354;
  94 
  95     /**
  96      * The {@code double} value that is closer than any other to
  97      * <i>pi</i>, the ratio of the circumference of a circle to its
  98      * diameter.
  99      */
 100     public static final double PI = 3.14159265358979323846;
 101 
 102     /**
 103      * Constant by which to multiply an angular value in degrees to obtain an
 104      * angular value in radians.
 105      */
 106     private static final double DEGREES_TO_RADIANS = 0.017453292519943295;
 107 
 108     /**
 109      * Constant by which to multiply an angular value in radians to obtain an
 110      * angular value in degrees.
 111      */
 112 
 113     private static final double RADIANS_TO_DEGREES = 57.29577951308232;
 114 
 115     /**
 116      * Returns the trigonometric sine of an angle. Special cases:
 117      * <ul><li>If the argument is NaN or an infinity, then the
 118      * result is NaN.
 119      * <li>If the argument is zero, then the result is a zero with the
 120      * same sign as the argument.</ul>
 121      *
 122      * @param   a   an angle, in radians.
 123      * @return  the sine of the argument.
 124      */
 125     public static native double sin(double a);
 126 
 127     /**
 128      * Returns the trigonometric cosine of an angle. Special cases:
 129      * <ul><li>If the argument is NaN or an infinity, then the
 130      * result is NaN.</ul>
 131      *
 132      * @param   a   an angle, in radians.
 133      * @return  the cosine of the argument.
 134      */
 135     public static native double cos(double a);
 136 
 137     /**
 138      * Returns the trigonometric tangent of an angle. Special cases:
 139      * <ul><li>If the argument is NaN or an infinity, then the result
 140      * is NaN.
 141      * <li>If the argument is zero, then the result is a zero with the
 142      * same sign as the argument.</ul>
 143      *
 144      * @param   a   an angle, in radians.
 145      * @return  the tangent of the argument.
 146      */
 147     public static native double tan(double a);
 148 
 149     /**
 150      * Returns the arc sine of a value; the returned angle is in the
 151      * range -<i>pi</i>/2 through <i>pi</i>/2.  Special cases:
 152      * <ul><li>If the argument is NaN or its absolute value is greater
 153      * than 1, then the result is NaN.
 154      * <li>If the argument is zero, then the result is a zero with the
 155      * same sign as the argument.</ul>
 156      *
 157      * @param   a   the value whose arc sine is to be returned.
 158      * @return  the arc sine of the argument.
 159      */
 160     public static native double asin(double a);
 161 
 162     /**
 163      * Returns the arc cosine of a value; the returned angle is in the
 164      * range 0.0 through <i>pi</i>.  Special case:
 165      * <ul><li>If the argument is NaN or its absolute value is greater
 166      * than 1, then the result is NaN.</ul>
 167      *
 168      * @param   a   the value whose arc cosine is to be returned.
 169      * @return  the arc cosine of the argument.
 170      */
 171     public static native double acos(double a);
 172 
 173     /**
 174      * Returns the arc tangent of a value; the returned angle is in the
 175      * range -<i>pi</i>/2 through <i>pi</i>/2.  Special cases:
 176      * <ul><li>If the argument is NaN, then the result is NaN.
 177      * <li>If the argument is zero, then the result is a zero with the
 178      * same sign as the argument.</ul>
 179      *
 180      * @param   a   the value whose arc tangent is to be returned.
 181      * @return  the arc tangent of the argument.
 182      */
 183     public static native double atan(double a);
 184 
 185     /**
 186      * Converts an angle measured in degrees to an approximately
 187      * equivalent angle measured in radians.  The conversion from
 188      * degrees to radians is generally inexact.
 189      *
 190      * @param   angdeg   an angle, in degrees
 191      * @return  the measurement of the angle {@code angdeg}
 192      *          in radians.
 193      */
 194     public static strictfp double toRadians(double angdeg) {
 195         // Do not delegate to Math.toRadians(angdeg) because
 196         // this method has the strictfp modifier.
 197         return angdeg * DEGREES_TO_RADIANS;
 198     }
 199 
 200     /**
 201      * Converts an angle measured in radians to an approximately
 202      * equivalent angle measured in degrees.  The conversion from
 203      * radians to degrees is generally inexact; users should
 204      * <i>not</i> expect {@code cos(toRadians(90.0))} to exactly
 205      * equal {@code 0.0}.
 206      *
 207      * @param   angrad   an angle, in radians
 208      * @return  the measurement of the angle {@code angrad}
 209      *          in degrees.
 210      */
 211     public static strictfp double toDegrees(double angrad) {
 212         // Do not delegate to Math.toDegrees(angrad) because
 213         // this method has the strictfp modifier.
 214         return angrad * RADIANS_TO_DEGREES;
 215     }
 216 
 217     /**
 218      * Returns Euler's number <i>e</i> raised to the power of a
 219      * {@code double} value. Special cases:
 220      * <ul><li>If the argument is NaN, the result is NaN.
 221      * <li>If the argument is positive infinity, then the result is
 222      * positive infinity.
 223      * <li>If the argument is negative infinity, then the result is
 224      * positive zero.</ul>
 225      *
 226      * @param   a   the exponent to raise <i>e</i> to.
 227      * @return  the value <i>e</i><sup>{@code a}</sup>,
 228      *          where <i>e</i> is the base of the natural logarithms.
 229      */
 230     public static double exp(double a) {
 231         return FdLibm.Exp.compute(a);
 232     }
 233 
 234     /**
 235      * Returns the natural logarithm (base <i>e</i>) of a {@code double}
 236      * value. Special cases:
 237      * <ul><li>If the argument is NaN or less than zero, then the result
 238      * is NaN.
 239      * <li>If the argument is positive infinity, then the result is
 240      * positive infinity.
 241      * <li>If the argument is positive zero or negative zero, then the
 242      * result is negative infinity.</ul>
 243      *
 244      * @param   a   a value
 245      * @return  the value ln&nbsp;{@code a}, the natural logarithm of
 246      *          {@code a}.
 247      */
 248     public static native double log(double a);
 249 
 250     /**
 251      * Returns the base 10 logarithm of a {@code double} value.
 252      * Special cases:
 253      *
 254      * <ul><li>If the argument is NaN or less than zero, then the result
 255      * is NaN.
 256      * <li>If the argument is positive infinity, then the result is
 257      * positive infinity.
 258      * <li>If the argument is positive zero or negative zero, then the
 259      * result is negative infinity.
 260      * <li> If the argument is equal to 10<sup><i>n</i></sup> for
 261      * integer <i>n</i>, then the result is <i>n</i>.
 262      * </ul>
 263      *
 264      * @param   a   a value
 265      * @return  the base 10 logarithm of  {@code a}.
 266      * @since 1.5
 267      */
 268     public static native double log10(double a);
 269 
 270     /**
 271      * Returns the correctly rounded positive square root of a
 272      * {@code double} value.
 273      * Special cases:
 274      * <ul><li>If the argument is NaN or less than zero, then the result
 275      * is NaN.
 276      * <li>If the argument is positive infinity, then the result is positive
 277      * infinity.
 278      * <li>If the argument is positive zero or negative zero, then the
 279      * result is the same as the argument.</ul>
 280      * Otherwise, the result is the {@code double} value closest to
 281      * the true mathematical square root of the argument value.
 282      *
 283      * @param   a   a value.
 284      * @return  the positive square root of {@code a}.
 285      */
 286     @HotSpotIntrinsicCandidate
 287     public static native double sqrt(double a);
 288 
 289     /**
 290      * Returns the cube root of a {@code double} value.  For
 291      * positive finite {@code x}, {@code cbrt(-x) ==
 292      * -cbrt(x)}; that is, the cube root of a negative value is
 293      * the negative of the cube root of that value's magnitude.
 294      * Special cases:
 295      *
 296      * <ul>
 297      *
 298      * <li>If the argument is NaN, then the result is NaN.
 299      *
 300      * <li>If the argument is infinite, then the result is an infinity
 301      * with the same sign as the argument.
 302      *
 303      * <li>If the argument is zero, then the result is a zero with the
 304      * same sign as the argument.
 305      *
 306      * </ul>
 307      *
 308      * @param   a   a value.
 309      * @return  the cube root of {@code a}.
 310      * @since 1.5
 311      */
 312     public static double cbrt(double a) {
 313         return FdLibm.Cbrt.compute(a);
 314     }
 315 
 316     /**
 317      * Computes the remainder operation on two arguments as prescribed
 318      * by the IEEE 754 standard.
 319      * The remainder value is mathematically equal to
 320      * <code>f1&nbsp;-&nbsp;f2</code>&nbsp;&times;&nbsp;<i>n</i>,
 321      * where <i>n</i> is the mathematical integer closest to the exact
 322      * mathematical value of the quotient {@code f1/f2}, and if two
 323      * mathematical integers are equally close to {@code f1/f2},
 324      * then <i>n</i> is the integer that is even. If the remainder is
 325      * zero, its sign is the same as the sign of the first argument.
 326      * Special cases:
 327      * <ul><li>If either argument is NaN, or the first argument is infinite,
 328      * or the second argument is positive zero or negative zero, then the
 329      * result is NaN.
 330      * <li>If the first argument is finite and the second argument is
 331      * infinite, then the result is the same as the first argument.</ul>
 332      *
 333      * @param   f1   the dividend.
 334      * @param   f2   the divisor.
 335      * @return  the remainder when {@code f1} is divided by
 336      *          {@code f2}.
 337      */
 338     public static native double IEEEremainder(double f1, double f2);
 339 
 340     /**
 341      * Returns the smallest (closest to negative infinity)
 342      * {@code double} value that is greater than or equal to the
 343      * argument and is equal to a mathematical integer. Special cases:
 344      * <ul><li>If the argument value is already equal to a
 345      * mathematical integer, then the result is the same as the
 346      * argument.  <li>If the argument is NaN or an infinity or
 347      * positive zero or negative zero, then the result is the same as
 348      * the argument.  <li>If the argument value is less than zero but
 349      * greater than -1.0, then the result is negative zero.</ul> Note
 350      * that the value of {@code StrictMath.ceil(x)} is exactly the
 351      * value of {@code -StrictMath.floor(-x)}.
 352      *
 353      * @param   a   a value.
 354      * @return  the smallest (closest to negative infinity)
 355      *          floating-point value that is greater than or equal to
 356      *          the argument and is equal to a mathematical integer.
 357      */
 358     public static double ceil(double a) {
 359         return floorOrCeil(a, -0.0, 1.0, 1.0);
 360     }
 361 
 362     /**
 363      * Returns the largest (closest to positive infinity)
 364      * {@code double} value that is less than or equal to the
 365      * argument and is equal to a mathematical integer. Special cases:
 366      * <ul><li>If the argument value is already equal to a
 367      * mathematical integer, then the result is the same as the
 368      * argument.  <li>If the argument is NaN or an infinity or
 369      * positive zero or negative zero, then the result is the same as
 370      * the argument.</ul>
 371      *
 372      * @param   a   a value.
 373      * @return  the largest (closest to positive infinity)
 374      *          floating-point value that less than or equal to the argument
 375      *          and is equal to a mathematical integer.
 376      */
 377     public static double floor(double a) {
 378         return floorOrCeil(a, -1.0, 0.0, -1.0);
 379     }
 380 
 381     /**
 382      * Internal method to share logic between floor and ceil.
 383      *
 384      * @param a the value to be floored or ceiled
 385      * @param negativeBoundary result for values in (-1, 0)
 386      * @param positiveBoundary result for values in (0, 1)
 387      * @param increment value to add when the argument is non-integral
 388      */
 389     private static double floorOrCeil(double a,
 390                                       double negativeBoundary,
 391                                       double positiveBoundary,
 392                                       double sign) {
 393         int exponent = Math.getExponent(a);
 394 
 395         if (exponent < 0) {
 396             /*
 397              * Absolute value of argument is less than 1.
 398              * floorOrceil(-0.0) => -0.0
 399              * floorOrceil(+0.0) => +0.0
 400              */
 401             return ((a == 0.0) ? a :
 402                     ( (a < 0.0) ?  negativeBoundary : positiveBoundary) );
 403         } else if (exponent >= 52) {
 404             /*
 405              * Infinity, NaN, or a value so large it must be integral.
 406              */
 407             return a;
 408         }
 409         // Else the argument is either an integral value already XOR it
 410         // has to be rounded to one.
 411         assert exponent >= 0 && exponent <= 51;
 412 
 413         long doppel = Double.doubleToRawLongBits(a);
 414         long mask   = DoubleConsts.SIGNIF_BIT_MASK >> exponent;
 415 
 416         if ( (mask & doppel) == 0L )
 417             return a; // integral value
 418         else {
 419             double result = Double.longBitsToDouble(doppel & (~mask));
 420             if (sign*a > 0.0)
 421                 result = result + sign;
 422             return result;
 423         }
 424     }
 425 
 426     /**
 427      * Returns the {@code double} value that is closest in value
 428      * to the argument and is equal to a mathematical integer. If two
 429      * {@code double} values that are mathematical integers are
 430      * equally close to the value of the argument, the result is the
 431      * integer value that is even. Special cases:
 432      * <ul><li>If the argument value is already equal to a mathematical
 433      * integer, then the result is the same as the argument.
 434      * <li>If the argument is NaN or an infinity or positive zero or negative
 435      * zero, then the result is the same as the argument.</ul>
 436      *
 437      * @param   a   a value.
 438      * @return  the closest floating-point value to {@code a} that is
 439      *          equal to a mathematical integer.
 440      * @author Joseph D. Darcy
 441      */
 442     public static double rint(double a) {
 443         /*
 444          * If the absolute value of a is not less than 2^52, it
 445          * is either a finite integer (the double format does not have
 446          * enough significand bits for a number that large to have any
 447          * fractional portion), an infinity, or a NaN.  In any of
 448          * these cases, rint of the argument is the argument.
 449          *
 450          * Otherwise, the sum (twoToThe52 + a ) will properly round
 451          * away any fractional portion of a since ulp(twoToThe52) ==
 452          * 1.0; subtracting out twoToThe52 from this sum will then be
 453          * exact and leave the rounded integer portion of a.
 454          *
 455          * This method does *not* need to be declared strictfp to get
 456          * fully reproducible results.  Whether or not a method is
 457          * declared strictfp can only make a difference in the
 458          * returned result if some operation would overflow or
 459          * underflow with strictfp semantics.  The operation
 460          * (twoToThe52 + a ) cannot overflow since large values of a
 461          * are screened out; the add cannot underflow since twoToThe52
 462          * is too large.  The subtraction ((twoToThe52 + a ) -
 463          * twoToThe52) will be exact as discussed above and thus
 464          * cannot overflow or meaningfully underflow.  Finally, the
 465          * last multiply in the return statement is by plus or minus
 466          * 1.0, which is exact too.
 467          */
 468         double twoToThe52 = (double)(1L << 52); // 2^52
 469         double sign = Math.copySign(1.0, a); // preserve sign info
 470         a = Math.abs(a);
 471 
 472         if (a < twoToThe52) { // E_min <= ilogb(a) <= 51
 473             a = ((twoToThe52 + a ) - twoToThe52);
 474         }
 475 
 476         return sign * a; // restore original sign
 477     }
 478 
 479     /**
 480      * Returns the angle <i>theta</i> from the conversion of rectangular
 481      * coordinates ({@code x},&nbsp;{@code y}) to polar
 482      * coordinates (r,&nbsp;<i>theta</i>).
 483      * This method computes the phase <i>theta</i> by computing an arc tangent
 484      * of {@code y/x} in the range of -<i>pi</i> to <i>pi</i>. Special
 485      * cases:
 486      * <ul><li>If either argument is NaN, then the result is NaN.
 487      * <li>If the first argument is positive zero and the second argument
 488      * is positive, or the first argument is positive and finite and the
 489      * second argument is positive infinity, then the result is positive
 490      * zero.
 491      * <li>If the first argument is negative zero and the second argument
 492      * is positive, or the first argument is negative and finite and the
 493      * second argument is positive infinity, then the result is negative zero.
 494      * <li>If the first argument is positive zero and the second argument
 495      * is negative, or the first argument is positive and finite and the
 496      * second argument is negative infinity, then the result is the
 497      * {@code double} value closest to <i>pi</i>.
 498      * <li>If the first argument is negative zero and the second argument
 499      * is negative, or the first argument is negative and finite and the
 500      * second argument is negative infinity, then the result is the
 501      * {@code double} value closest to -<i>pi</i>.
 502      * <li>If the first argument is positive and the second argument is
 503      * positive zero or negative zero, or the first argument is positive
 504      * infinity and the second argument is finite, then the result is the
 505      * {@code double} value closest to <i>pi</i>/2.
 506      * <li>If the first argument is negative and the second argument is
 507      * positive zero or negative zero, or the first argument is negative
 508      * infinity and the second argument is finite, then the result is the
 509      * {@code double} value closest to -<i>pi</i>/2.
 510      * <li>If both arguments are positive infinity, then the result is the
 511      * {@code double} value closest to <i>pi</i>/4.
 512      * <li>If the first argument is positive infinity and the second argument
 513      * is negative infinity, then the result is the {@code double}
 514      * value closest to 3*<i>pi</i>/4.
 515      * <li>If the first argument is negative infinity and the second argument
 516      * is positive infinity, then the result is the {@code double} value
 517      * closest to -<i>pi</i>/4.
 518      * <li>If both arguments are negative infinity, then the result is the
 519      * {@code double} value closest to -3*<i>pi</i>/4.</ul>
 520      *
 521      * @param   y   the ordinate coordinate
 522      * @param   x   the abscissa coordinate
 523      * @return  the <i>theta</i> component of the point
 524      *          (<i>r</i>,&nbsp;<i>theta</i>)
 525      *          in polar coordinates that corresponds to the point
 526      *          (<i>x</i>,&nbsp;<i>y</i>) in Cartesian coordinates.
 527      */
 528     public static native double atan2(double y, double x);
 529 
 530     /**
 531      * Returns the value of the first argument raised to the power of the
 532      * second argument. Special cases:
 533      *
 534      * <ul><li>If the second argument is positive or negative zero, then the
 535      * result is 1.0.
 536      * <li>If the second argument is 1.0, then the result is the same as the
 537      * first argument.
 538      * <li>If the second argument is NaN, then the result is NaN.
 539      * <li>If the first argument is NaN and the second argument is nonzero,
 540      * then the result is NaN.
 541      *
 542      * <li>If
 543      * <ul>
 544      * <li>the absolute value of the first argument is greater than 1
 545      * and the second argument is positive infinity, or
 546      * <li>the absolute value of the first argument is less than 1 and
 547      * the second argument is negative infinity,
 548      * </ul>
 549      * then the result is positive infinity.
 550      *
 551      * <li>If
 552      * <ul>
 553      * <li>the absolute value of the first argument is greater than 1 and
 554      * the second argument is negative infinity, or
 555      * <li>the absolute value of the
 556      * first argument is less than 1 and the second argument is positive
 557      * infinity,
 558      * </ul>
 559      * then the result is positive zero.
 560      *
 561      * <li>If the absolute value of the first argument equals 1 and the
 562      * second argument is infinite, then the result is NaN.
 563      *
 564      * <li>If
 565      * <ul>
 566      * <li>the first argument is positive zero and the second argument
 567      * is greater than zero, or
 568      * <li>the first argument is positive infinity and the second
 569      * argument is less than zero,
 570      * </ul>
 571      * then the result is positive zero.
 572      *
 573      * <li>If
 574      * <ul>
 575      * <li>the first argument is positive zero and the second argument
 576      * is less than zero, or
 577      * <li>the first argument is positive infinity and the second
 578      * argument is greater than zero,
 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 greater than zero but not a finite odd integer, or
 586      * <li>the first argument is negative infinity and the second
 587      * argument is less than zero but not a finite odd integer,
 588      * </ul>
 589      * then the result is positive zero.
 590      *
 591      * <li>If
 592      * <ul>
 593      * <li>the first argument is negative zero and the second argument
 594      * is a positive finite odd integer, or
 595      * <li>the first argument is negative infinity and the second
 596      * argument is a negative finite odd integer,
 597      * </ul>
 598      * then the result is negative zero.
 599      *
 600      * <li>If
 601      * <ul>
 602      * <li>the first argument is negative zero and the second argument
 603      * is less than zero but not a finite odd integer, or
 604      * <li>the first argument is negative infinity and the second
 605      * argument is greater than zero but not a finite odd integer,
 606      * </ul>
 607      * then the result is positive infinity.
 608      *
 609      * <li>If
 610      * <ul>
 611      * <li>the first argument is negative zero and the second argument
 612      * is a negative finite odd integer, or
 613      * <li>the first argument is negative infinity and the second
 614      * argument is a positive finite odd integer,
 615      * </ul>
 616      * then the result is negative infinity.
 617      *
 618      * <li>If the first argument is finite and less than zero
 619      * <ul>
 620      * <li> if the second argument is a finite even integer, the
 621      * result is equal to the result of raising the absolute value of
 622      * the first argument to the power of the second argument
 623      *
 624      * <li>if the second argument is a finite odd integer, the result
 625      * is equal to the negative of the result of raising the absolute
 626      * value of the first argument to the power of the second
 627      * argument
 628      *
 629      * <li>if the second argument is finite and not an integer, then
 630      * the result is NaN.
 631      * </ul>
 632      *
 633      * <li>If both arguments are integers, then the result is exactly equal
 634      * to the mathematical result of raising the first argument to the power
 635      * of the second argument if that result can in fact be represented
 636      * exactly as a {@code double} value.</ul>
 637      *
 638      * <p>(In the foregoing descriptions, a floating-point value is
 639      * considered to be an integer if and only if it is finite and a
 640      * fixed point of the method {@link #ceil ceil} or,
 641      * equivalently, a fixed point of the method {@link #floor
 642      * floor}. A value is a fixed point of a one-argument
 643      * method if and only if the result of applying the method to the
 644      * value is equal to the value.)
 645      *
 646      * @param   a   base.
 647      * @param   b   the exponent.
 648      * @return  the value {@code a}<sup>{@code b}</sup>.
 649      */
 650     public static double pow(double a, double b) {
 651         return FdLibm.Pow.compute(a, b);
 652     }
 653 
 654     /**
 655      * Returns the closest {@code int} to the argument, with ties
 656      * rounding to positive infinity.
 657      *
 658      * <p>Special cases:
 659      * <ul><li>If the argument is NaN, the result is 0.
 660      * <li>If the argument is negative infinity or any value less than or
 661      * equal to the value of {@code Integer.MIN_VALUE}, the result is
 662      * equal to the value of {@code Integer.MIN_VALUE}.
 663      * <li>If the argument is positive infinity or any value greater than or
 664      * equal to the value of {@code Integer.MAX_VALUE}, the result is
 665      * equal to the value of {@code Integer.MAX_VALUE}.</ul>
 666      *
 667      * @param   a   a floating-point value to be rounded to an integer.
 668      * @return  the value of the argument rounded to the nearest
 669      *          {@code int} value.
 670      * @see     java.lang.Integer#MAX_VALUE
 671      * @see     java.lang.Integer#MIN_VALUE
 672      */
 673     public static int round(float a) {
 674         return Math.round(a);
 675     }
 676 
 677     /**
 678      * Returns the closest {@code long} to the argument, with ties
 679      * rounding to positive infinity.
 680      *
 681      * <p>Special cases:
 682      * <ul><li>If the argument is NaN, the result is 0.
 683      * <li>If the argument is negative infinity or any value less than or
 684      * equal to the value of {@code Long.MIN_VALUE}, the result is
 685      * equal to the value of {@code Long.MIN_VALUE}.
 686      * <li>If the argument is positive infinity or any value greater than or
 687      * equal to the value of {@code Long.MAX_VALUE}, the result is
 688      * equal to the value of {@code Long.MAX_VALUE}.</ul>
 689      *
 690      * @param   a  a floating-point value to be rounded to a
 691      *          {@code long}.
 692      * @return  the value of the argument rounded to the nearest
 693      *          {@code long} value.
 694      * @see     java.lang.Long#MAX_VALUE
 695      * @see     java.lang.Long#MIN_VALUE
 696      */
 697     public static long round(double a) {
 698         return Math.round(a);
 699     }
 700 
 701     private static final class RandomNumberGeneratorHolder {
 702         static final Random randomNumberGenerator = new Random();
 703     }
 704 
 705     /**
 706      * Returns a {@code double} value with a positive sign, greater
 707      * than or equal to {@code 0.0} and less than {@code 1.0}.
 708      * Returned values are chosen pseudorandomly with (approximately)
 709      * uniform distribution from that range.
 710      *
 711      * <p>When this method is first called, it creates a single new
 712      * pseudorandom-number generator, exactly as if by the expression
 713      *
 714      * <blockquote>{@code new java.util.Random()}</blockquote>
 715      *
 716      * This new pseudorandom-number generator is used thereafter for
 717      * all calls to this method and is used nowhere else.
 718      *
 719      * <p>This method is properly synchronized to allow correct use by
 720      * more than one thread. However, if many threads need to generate
 721      * pseudorandom numbers at a great rate, it may reduce contention
 722      * for each thread to have its own pseudorandom-number generator.
 723      *
 724      * @return  a pseudorandom {@code double} greater than or equal
 725      * to {@code 0.0} and less than {@code 1.0}.
 726      * @see Random#nextDouble()
 727      */
 728     public static double random() {
 729         return RandomNumberGeneratorHolder.randomNumberGenerator.nextDouble();
 730     }
 731 
 732     /**
 733      * Returns the sum of its arguments,
 734      * throwing an exception if the result overflows an {@code int}.
 735      *
 736      * @param x the first value
 737      * @param y the second value
 738      * @return the result
 739      * @throws ArithmeticException if the result overflows an int
 740      * @see Math#addExact(int,int)
 741      * @since 1.8
 742      */
 743     public static int addExact(int x, int y) {
 744         return Math.addExact(x, y);
 745     }
 746 
 747     /**
 748      * Returns the sum of its arguments,
 749      * throwing an exception if the result overflows a {@code long}.
 750      *
 751      * @param x the first value
 752      * @param y the second value
 753      * @return the result
 754      * @throws ArithmeticException if the result overflows a long
 755      * @see Math#addExact(long,long)
 756      * @since 1.8
 757      */
 758     public static long addExact(long x, long y) {
 759         return Math.addExact(x, y);
 760     }
 761 
 762     /**
 763      * Returns the difference of the arguments,
 764      * throwing an exception if the result overflows an {@code int}.
 765      *
 766      * @param x the first value
 767      * @param y the second value to subtract from the first
 768      * @return the result
 769      * @throws ArithmeticException if the result overflows an int
 770      * @see Math#subtractExact(int,int)
 771      * @since 1.8
 772      */
 773     public static int subtractExact(int x, int y) {
 774         return Math.subtractExact(x, y);
 775     }
 776 
 777     /**
 778      * Returns the difference of the arguments,
 779      * throwing an exception if the result overflows a {@code long}.
 780      *
 781      * @param x the first value
 782      * @param y the second value to subtract from the first
 783      * @return the result
 784      * @throws ArithmeticException if the result overflows a long
 785      * @see Math#subtractExact(long,long)
 786      * @since 1.8
 787      */
 788     public static long subtractExact(long x, long y) {
 789         return Math.subtractExact(x, y);
 790     }
 791 
 792     /**
 793      * Returns the product of the arguments,
 794      * throwing an exception if the result overflows an {@code int}.
 795      *
 796      * @param x the first value
 797      * @param y the second value
 798      * @return the result
 799      * @throws ArithmeticException if the result overflows an int
 800      * @see Math#multiplyExact(int,int)
 801      * @since 1.8
 802      */
 803     public static int multiplyExact(int x, int y) {
 804         return Math.multiplyExact(x, y);
 805     }
 806 
 807     /**
 808      * Returns the product of the arguments, throwing an exception if the result
 809      * overflows a {@code long}.
 810      *
 811      * @param x the first value
 812      * @param y the second value
 813      * @return the result
 814      * @throws ArithmeticException if the result overflows a long
 815      * @see Math#multiplyExact(long,int)
 816      * @since 9
 817      */
 818     public static long multiplyExact(long x, int y) {
 819         return Math.multiplyExact(x, y);
 820     }
 821 
 822     /**
 823      * Returns the product of the arguments,
 824      * throwing an exception if the result overflows a {@code long}.
 825      *
 826      * @param x the first value
 827      * @param y the second value
 828      * @return the result
 829      * @throws ArithmeticException if the result overflows a long
 830      * @see Math#multiplyExact(long,long)
 831      * @since 1.8
 832      */
 833     public static long multiplyExact(long x, long y) {
 834         return Math.multiplyExact(x, y);
 835     }
 836 
 837     /**
 838      * Returns the argument incremented by one, throwing an exception if the
 839      * result overflows an {@code int}.
 840      *
 841      * @param a the value to increment
 842      * @return the result
 843      * @throws ArithmeticException if the result overflows an int
 844      * @since 1.8
 845      */
 846     public static int incrementExact(int a) {
 847         return Math.incrementExact(a);
 848     }
 849 
 850     /**
 851      * Returns the argument incremented by one, throwing an exception if the
 852      * result overflows a {@code long}.
 853      *
 854      * @param a the value to increment
 855      * @return the result
 856      * @throws ArithmeticException if the result overflows a long
 857      * @since 1.8
 858      */
 859     public static long incrementExact(long a) {
 860         return Math.incrementExact(a);
 861     }
 862 
 863     /**
 864      * Returns the argument decremented by one, throwing an exception if the
 865      * result overflows an {@code int}.
 866      *
 867      * @param a the value to decrement
 868      * @return the result
 869      * @throws ArithmeticException if the result overflows an int
 870      * @since 1.8
 871      */
 872     public static int decrementExact(int a) {
 873         return Math.decrementExact(a);
 874     }
 875 
 876     /**
 877      * Returns the argument decremented by one, throwing an exception if the
 878      * result overflows a {@code long}.
 879      *
 880      * @param a the value to decrement
 881      * @return the result
 882      * @throws ArithmeticException if the result overflows a long
 883      * @since 1.8
 884      */
 885     public static long decrementExact(long a) {
 886         return Math.decrementExact(a);
 887     }
 888 
 889     /**
 890      * Returns the negation of the argument, throwing an exception if the
 891      * result overflows an {@code int}.
 892      *
 893      * @param a the value to negate
 894      * @return the result
 895      * @throws ArithmeticException if the result overflows an int
 896      * @since 1.8
 897      */
 898     public static int negateExact(int a) {
 899         return Math.negateExact(a);
 900     }
 901 
 902     /**
 903      * Returns the negation of the argument, throwing an exception if the
 904      * result overflows a {@code long}.
 905      *
 906      * @param a the value to negate
 907      * @return the result
 908      * @throws ArithmeticException if the result overflows a long
 909      * @since 1.8
 910      */
 911     public static long negateExact(long a) {
 912         return Math.negateExact(a);
 913     }
 914 
 915     /**
 916      * Returns the value of the {@code long} argument;
 917      * throwing an exception if the value overflows an {@code int}.
 918      *
 919      * @param value the long value
 920      * @return the argument as an int
 921      * @throws ArithmeticException if the {@code argument} overflows an int
 922      * @see Math#toIntExact(long)
 923      * @since 1.8
 924      */
 925     public static int toIntExact(long value) {
 926         return Math.toIntExact(value);
 927     }
 928 
 929     /**
 930      * Returns the exact mathematical product of the arguments.
 931      *
 932      * @param x the first value
 933      * @param y the second value
 934      * @return the result
 935      * @see Math#multiplyFull(int,int)
 936      * @since 9
 937      */
 938     public static long multiplyFull(int x, int y) {
 939         return Math.multiplyFull(x, y);
 940     }
 941 
 942     /**
 943      * Returns as a {@code long} the most significant 64 bits of the 128-bit
 944      * product of two 64-bit factors.
 945      *
 946      * @param x the first value
 947      * @param y the second value
 948      * @return the result
 949      * @see Math#multiplyHigh(long,long)
 950      * @since 9
 951      */
 952     public static long multiplyHigh(long x, long y) {
 953         return Math.multiplyHigh(x, y);
 954     }
 955 
 956     /**
 957      * Returns the largest (closest to positive infinity)
 958      * {@code int} value that is less than or equal to the algebraic quotient.
 959      * There is one special case, if the dividend is the
 960      * {@linkplain Integer#MIN_VALUE Integer.MIN_VALUE} and the divisor is {@code -1},
 961      * then integer overflow occurs and
 962      * the result is equal to the {@code Integer.MIN_VALUE}.
 963      * <p>
 964      * See {@link Math#floorDiv(int, int) Math.floorDiv} for examples and
 965      * a comparison to the integer division {@code /} operator.
 966      *
 967      * @param x the dividend
 968      * @param y the divisor
 969      * @return the largest (closest to positive infinity)
 970      * {@code int} value that is less than or equal to the algebraic quotient.
 971      * @throws ArithmeticException if the divisor {@code y} is zero
 972      * @see Math#floorDiv(int, int)
 973      * @see Math#floor(double)
 974      * @since 1.8
 975      */
 976     public static int floorDiv(int x, int y) {
 977         return Math.floorDiv(x, y);
 978     }
 979 
 980     /**
 981      * Returns the largest (closest to positive infinity)
 982      * {@code long} value that is less than or equal to the algebraic quotient.
 983      * There is one special case, if the dividend is the
 984      * {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1},
 985      * then integer overflow occurs and
 986      * the result is equal to {@code Long.MIN_VALUE}.
 987      * <p>
 988      * See {@link Math#floorDiv(int, int) Math.floorDiv} for examples and
 989      * a comparison to the integer division {@code /} operator.
 990      *
 991      * @param x the dividend
 992      * @param y the divisor
 993      * @return the largest (closest to positive infinity)
 994      * {@code int} value that is less than or equal to the algebraic quotient.
 995      * @throws ArithmeticException if the divisor {@code y} is zero
 996      * @see Math#floorDiv(long, int)
 997      * @see Math#floor(double)
 998      * @since 9
 999      */
1000     public static long floorDiv(long x, int y) {
1001         return Math.floorDiv(x, y);
1002     }
1003 
1004     /**
1005      * Returns the largest (closest to positive infinity)
1006      * {@code long} value that is less than or equal to the algebraic quotient.
1007      * There is one special case, if the dividend is the
1008      * {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1},
1009      * then integer overflow occurs and
1010      * the result is equal to the {@code Long.MIN_VALUE}.
1011      * <p>
1012      * See {@link Math#floorDiv(int, int) Math.floorDiv} for examples and
1013      * a comparison to the integer division {@code /} operator.
1014      *
1015      * @param x the dividend
1016      * @param y the divisor
1017      * @return the largest (closest to positive infinity)
1018      * {@code long} value that is less than or equal to the algebraic quotient.
1019      * @throws ArithmeticException if the divisor {@code y} is zero
1020      * @see Math#floorDiv(long, long)
1021      * @see Math#floor(double)
1022      * @since 1.8
1023      */
1024     public static long floorDiv(long x, long y) {
1025         return Math.floorDiv(x, y);
1026     }
1027 
1028     /**
1029      * Returns the floor modulus of the {@code int} arguments.
1030      * <p>
1031      * The floor modulus is {@code x - (floorDiv(x, y) * y)},
1032      * has the same sign as the divisor {@code y}, and
1033      * is in the range of {@code -abs(y) < r < +abs(y)}.
1034      * <p>
1035      * The relationship between {@code floorDiv} and {@code floorMod} is such that:
1036      * <ul>
1037      *   <li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}
1038      * </ul>
1039      * <p>
1040      * See {@link Math#floorMod(int, int) Math.floorMod} for examples and
1041      * a comparison to the {@code %} operator.
1042      *
1043      * @param x the dividend
1044      * @param y the divisor
1045      * @return the floor modulus {@code x - (floorDiv(x, y) * y)}
1046      * @throws ArithmeticException if the divisor {@code y} is zero
1047      * @see Math#floorMod(int, int)
1048      * @see StrictMath#floorDiv(int, int)
1049      * @since 1.8
1050      */
1051     public static int floorMod(int x, int y) {
1052         return Math.floorMod(x , y);
1053     }
1054 
1055     /**
1056      * Returns the floor modulus of the {@code long} and {@code int} arguments.
1057      * <p>
1058      * The floor modulus is {@code x - (floorDiv(x, y) * y)},
1059      * has the same sign as the divisor {@code y}, and
1060      * is in the range of {@code -abs(y) < r < +abs(y)}.
1061      *
1062      * <p>
1063      * The relationship between {@code floorDiv} and {@code floorMod} is such that:
1064      * <ul>
1065      *   <li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}
1066      * </ul>
1067      * <p>
1068      * See {@link Math#floorMod(int, int) Math.floorMod} for examples and
1069      * a comparison to the {@code %} operator.
1070      *
1071      * @param x the dividend
1072      * @param y the divisor
1073      * @return the floor modulus {@code x - (floorDiv(x, y) * y)}
1074      * @throws ArithmeticException if the divisor {@code y} is zero
1075      * @see Math#floorMod(long, int)
1076      * @see StrictMath#floorDiv(long, int)
1077      * @since 9
1078      */
1079     public static int floorMod(long x, int y) {
1080         return Math.floorMod(x , y);
1081     }
1082 
1083     /**
1084      * Returns the floor modulus of the {@code long} arguments.
1085      * <p>
1086      * The floor modulus is {@code x - (floorDiv(x, y) * y)},
1087      * has the same sign as the divisor {@code y}, and
1088      * is in the range of {@code -abs(y) < r < +abs(y)}.
1089      * <p>
1090      * The relationship between {@code floorDiv} and {@code floorMod} is such that:
1091      * <ul>
1092      *   <li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}
1093      * </ul>
1094      * <p>
1095      * See {@link Math#floorMod(int, int) Math.floorMod} for examples and
1096      * a comparison to the {@code %} operator.
1097      *
1098      * @param x the dividend
1099      * @param y the divisor
1100      * @return the floor modulus {@code x - (floorDiv(x, y) * y)}
1101      * @throws ArithmeticException if the divisor {@code y} is zero
1102      * @see Math#floorMod(long, long)
1103      * @see StrictMath#floorDiv(long, long)
1104      * @since 1.8
1105      */
1106     public static long floorMod(long x, long y) {
1107         return Math.floorMod(x, y);
1108     }
1109 
1110     /**
1111      * Returns the absolute value of an {@code int} value.
1112      * If the argument is not negative, the argument is returned.
1113      * If the argument is negative, the negation of the argument is returned.
1114      *
1115      * <p>Note that if the argument is equal to the value of
1116      * {@link Integer#MIN_VALUE}, the most negative representable
1117      * {@code int} value, the result is that same value, which is
1118      * negative.
1119      *
1120      * @param   a   the  argument whose absolute value is to be determined.
1121      * @return  the absolute value of the argument.
1122      */
1123     public static int abs(int a) {
1124         return Math.abs(a);
1125     }
1126 
1127     /**
1128      * Returns the absolute value of a {@code long} value.
1129      * If the argument is not negative, the argument is returned.
1130      * If the argument is negative, the negation of the argument is returned.
1131      *
1132      * <p>Note that if the argument is equal to the value of
1133      * {@link Long#MIN_VALUE}, the most negative representable
1134      * {@code long} value, the result is that same value, which
1135      * is negative.
1136      *
1137      * @param   a   the  argument whose absolute value is to be determined.
1138      * @return  the absolute value of the argument.
1139      */
1140     public static long abs(long a) {
1141         return Math.abs(a);
1142     }
1143 
1144     /**
1145      * Returns the absolute value of a {@code float} value.
1146      * If the argument is not negative, the argument is returned.
1147      * If the argument is negative, the negation of the argument is returned.
1148      * Special cases:
1149      * <ul><li>If the argument is positive zero or negative zero, the
1150      * result is positive zero.
1151      * <li>If the argument is infinite, the result is positive infinity.
1152      * <li>If the argument is NaN, the result is NaN.</ul>
1153      *
1154      * @apiNote As implied by the above, one valid implementation of
1155      * this method is given by the expression below which computes a
1156      * {@code float} with the same exponent and significand as the
1157      * argument but with a guaranteed zero sign bit indicating a
1158      * positive value: <br>
1159      * {@code Float.intBitsToFloat(0x7fffffff & Float.floatToRawIntBits(a))}
1160      *
1161      * @param   a   the argument whose absolute value is to be determined
1162      * @return  the absolute value of the argument.
1163      */
1164     public static float abs(float a) {
1165         return Math.abs(a);
1166     }
1167 
1168     /**
1169      * Returns the absolute value of a {@code double} value.
1170      * If the argument is not negative, the argument is returned.
1171      * If the argument is negative, the negation of the argument is returned.
1172      * Special cases:
1173      * <ul><li>If the argument is positive zero or negative zero, the result
1174      * is positive zero.
1175      * <li>If the argument is infinite, the result is positive infinity.
1176      * <li>If the argument is NaN, the result is NaN.</ul>
1177      *
1178      * @apiNote As implied by the above, one valid implementation of
1179      * this method is given by the expression below which computes a
1180      * {@code double} with the same exponent and significand as the
1181      * argument but with a guaranteed zero sign bit indicating a
1182      * positive value: <br>
1183      * {@code Double.longBitsToDouble((Double.doubleToRawLongBits(a)<<1)>>>1)}
1184      *
1185      * @param   a   the argument whose absolute value is to be determined
1186      * @return  the absolute value of the argument.
1187      */
1188     public static double abs(double a) {
1189         return Math.abs(a);
1190     }
1191 
1192     /**
1193      * Returns the greater of two {@code int} values. That is, the
1194      * result is the argument closer to the value of
1195      * {@link Integer#MAX_VALUE}. If the arguments have the same value,
1196      * the result is that same value.
1197      *
1198      * @param   a   an argument.
1199      * @param   b   another argument.
1200      * @return  the larger of {@code a} and {@code b}.
1201      */
1202     @HotSpotIntrinsicCandidate
1203     public static int max(int a, int b) {
1204         return Math.max(a, b);
1205     }
1206 
1207     /**
1208      * Returns the greater of two {@code long} values. That is, the
1209      * result is the argument closer to the value of
1210      * {@link Long#MAX_VALUE}. If the arguments have the same value,
1211      * the result is that same value.
1212      *
1213      * @param   a   an argument.
1214      * @param   b   another argument.
1215      * @return  the larger of {@code a} and {@code b}.
1216         */
1217     public static long max(long a, long b) {
1218         return Math.max(a, b);
1219     }
1220 
1221     /**
1222      * Returns the greater of two {@code float} values.  That is,
1223      * the result is the argument closer to positive infinity. If the
1224      * arguments have the same value, the result is that same
1225      * value. If either value is NaN, then the result is NaN.  Unlike
1226      * the numerical comparison operators, this method considers
1227      * negative zero to be strictly smaller than positive zero. If one
1228      * argument is positive zero and the other negative zero, the
1229      * result is positive zero.
1230      *
1231      * @param   a   an argument.
1232      * @param   b   another argument.
1233      * @return  the larger of {@code a} and {@code b}.
1234      */
1235     @HotSpotIntrinsicCandidate
1236     public static float max(float a, float b) {
1237         return Math.max(a, b);
1238     }
1239 
1240     /**
1241      * Returns the greater of two {@code double} values.  That
1242      * is, the result is the argument closer to positive infinity. If
1243      * the arguments have the same value, the result is that same
1244      * value. If either value is NaN, then the result is NaN.  Unlike
1245      * the numerical comparison operators, this method considers
1246      * negative zero to be strictly smaller than positive zero. If one
1247      * argument is positive zero and the other negative zero, the
1248      * result is positive zero.
1249      *
1250      * @param   a   an argument.
1251      * @param   b   another argument.
1252      * @return  the larger of {@code a} and {@code b}.
1253      */
1254     @HotSpotIntrinsicCandidate
1255     public static double max(double a, double b) {
1256         return Math.max(a, b);
1257     }
1258 
1259     /**
1260      * Returns the smaller of two {@code int} values. That is,
1261      * the result the argument closer to the value of
1262      * {@link Integer#MIN_VALUE}.  If the arguments have the same
1263      * value, the result is that same value.
1264      *
1265      * @param   a   an argument.
1266      * @param   b   another argument.
1267      * @return  the smaller of {@code a} and {@code b}.
1268      */
1269     @HotSpotIntrinsicCandidate
1270     public static int min(int a, int b) {
1271         return Math.min(a, b);
1272     }
1273 
1274     /**
1275      * Returns the smaller of two {@code long} values. That is,
1276      * the result is the argument closer to the value of
1277      * {@link Long#MIN_VALUE}. If the arguments have the same
1278      * value, the result is that same value.
1279      *
1280      * @param   a   an argument.
1281      * @param   b   another argument.
1282      * @return  the smaller of {@code a} and {@code b}.
1283      */
1284     public static long min(long a, long b) {
1285         return Math.min(a, b);
1286     }
1287 
1288     /**
1289      * Returns the smaller of two {@code float} values.  That is,
1290      * the result is the value closer to negative infinity. If the
1291      * arguments have the same value, the result is that same
1292      * value. If either value is NaN, then the result is NaN.  Unlike
1293      * the numerical comparison operators, this method considers
1294      * negative zero to be strictly smaller than positive zero.  If
1295      * one argument is positive zero and the other is negative zero,
1296      * the result is negative zero.
1297      *
1298      * @param   a   an argument.
1299      * @param   b   another argument.
1300      * @return  the smaller of {@code a} and {@code b.}
1301      */
1302     @HotSpotIntrinsicCandidate
1303     public static float min(float a, float b) {
1304         return Math.min(a, b);
1305     }
1306 
1307     /**
1308      * Returns the smaller of two {@code double} values.  That
1309      * is, the result is the value closer to negative infinity. If the
1310      * arguments have the same value, the result is that same
1311      * value. If either value is NaN, then the result is NaN.  Unlike
1312      * the numerical comparison operators, this method considers
1313      * negative zero to be strictly smaller than positive zero. If one
1314      * argument is positive zero and the other is negative zero, the
1315      * result is negative zero.
1316      *
1317      * @param   a   an argument.
1318      * @param   b   another argument.
1319      * @return  the smaller of {@code a} and {@code b}.
1320      */
1321     @HotSpotIntrinsicCandidate
1322     public static double min(double a, double b) {
1323         return Math.min(a, b);
1324     }
1325 
1326     /**
1327      * Returns the fused multiply add of the three arguments; that is,
1328      * returns the exact product of the first two arguments summed
1329      * with the third argument and then rounded once to the nearest
1330      * {@code double}.
1331      *
1332      * The rounding is done using the {@linkplain
1333      * java.math.RoundingMode#HALF_EVEN round to nearest even
1334      * rounding mode}.
1335      *
1336      * In contrast, if {@code a * b + c} is evaluated as a regular
1337      * floating-point expression, two rounding errors are involved,
1338      * the first for the multiply operation, the second for the
1339      * addition operation.
1340      *
1341      * <p>Special cases:
1342      * <ul>
1343      * <li> If any argument is NaN, the result is NaN.
1344      *
1345      * <li> If one of the first two arguments is infinite and the
1346      * other is zero, the result is NaN.
1347      *
1348      * <li> If the exact product of the first two arguments is infinite
1349      * (in other words, at least one of the arguments is infinite and
1350      * the other is neither zero nor NaN) and the third argument is an
1351      * infinity of the opposite sign, the result is NaN.
1352      *
1353      * </ul>
1354      *
1355      * <p>Note that {@code fusedMac(a, 1.0, c)} returns the same
1356      * result as ({@code a + c}).  However,
1357      * {@code fusedMac(a, b, +0.0)} does <em>not</em> always return the
1358      * same result as ({@code a * b}) since
1359      * {@code fusedMac(-0.0, +0.0, +0.0)} is {@code +0.0} while
1360      * ({@code -0.0 * +0.0}) is {@code -0.0}; {@code fusedMac(a, b, -0.0)} is
1361      * equivalent to ({@code a * b}) however.
1362      *
1363      * @apiNote This method corresponds to the fusedMultiplyAdd
1364      * operation defined in IEEE 754-2008.
1365      *
1366      * @param a a value
1367      * @param b a value
1368      * @param c a value
1369      *
1370      * @return (<i>a</i>&nbsp;&times;&nbsp;<i>b</i>&nbsp;+&nbsp;<i>c</i>)
1371      * computed, as if with unlimited range and precision, and rounded
1372      * once to the nearest {@code double} value
1373      *
1374      * @since 9
1375      */
1376     public static double fma(double a, double b, double c) {
1377         return Math.fma(a, b, c);
1378     }
1379 
1380     /**
1381      * Returns the fused multiply add of the three arguments; that is,
1382      * returns the exact product of the first two arguments summed
1383      * with the third argument and then rounded once to the nearest
1384      * {@code float}.
1385      *
1386      * The rounding is done using the {@linkplain
1387      * java.math.RoundingMode#HALF_EVEN round to nearest even
1388      * rounding mode}.
1389      *
1390      * In contrast, if {@code a * b + c} is evaluated as a regular
1391      * floating-point expression, two rounding errors are involved,
1392      * the first for the multiply operation, the second for the
1393      * addition operation.
1394      *
1395      * <p>Special cases:
1396      * <ul>
1397      * <li> If any argument is NaN, the result is NaN.
1398      *
1399      * <li> If one of the first two arguments is infinite and the
1400      * other is zero, the result is NaN.
1401      *
1402      * <li> If the exact product of the first two arguments is infinite
1403      * (in other words, at least one of the arguments is infinite and
1404      * the other is neither zero nor NaN) and the third argument is an
1405      * infinity of the opposite sign, the result is NaN.
1406      *
1407      * </ul>
1408      *
1409      * <p>Note that {@code fma(a, 1.0f, c)} returns the same
1410      * result as ({@code a + c}).  However,
1411      * {@code fma(a, b, +0.0f)} does <em>not</em> always return the
1412      * same result as ({@code a * b}) since
1413      * {@code fma(-0.0f, +0.0f, +0.0f)} is {@code +0.0f} while
1414      * ({@code -0.0f * +0.0f}) is {@code -0.0f}; {@code fma(a, b, -0.0f)} is
1415      * equivalent to ({@code a * b}) however.
1416      *
1417      * @apiNote This method corresponds to the fusedMultiplyAdd
1418      * operation defined in IEEE 754-2008.
1419      *
1420      * @param a a value
1421      * @param b a value
1422      * @param c a value
1423      *
1424      * @return (<i>a</i>&nbsp;&times;&nbsp;<i>b</i>&nbsp;+&nbsp;<i>c</i>)
1425      * computed, as if with unlimited range and precision, and rounded
1426      * once to the nearest {@code float} value
1427      *
1428      * @since 9
1429      */
1430     public static float fma(float a, float b, float c) {
1431         return Math.fma(a, b, c);
1432     }
1433 
1434     /**
1435      * Returns the size of an ulp of the argument.  An ulp, unit in
1436      * the last place, of a {@code double} value is the positive
1437      * distance between this floating-point value and the {@code
1438      * double} value next larger in magnitude.  Note that for non-NaN
1439      * <i>x</i>, <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
1440      *
1441      * <p>Special Cases:
1442      * <ul>
1443      * <li> If the argument is NaN, then the result is NaN.
1444      * <li> If the argument is positive or negative infinity, then the
1445      * result is positive infinity.
1446      * <li> If the argument is positive or negative zero, then the result is
1447      * {@code Double.MIN_VALUE}.
1448      * <li> If the argument is &plusmn;{@code Double.MAX_VALUE}, then
1449      * the result is equal to 2<sup>971</sup>.
1450      * </ul>
1451      *
1452      * @param d the floating-point value whose ulp is to be returned
1453      * @return the size of an ulp of the argument
1454      * @author Joseph D. Darcy
1455      * @since 1.5
1456      */
1457     public static double ulp(double d) {
1458         return Math.ulp(d);
1459     }
1460 
1461     /**
1462      * Returns the size of an ulp of the argument.  An ulp, unit in
1463      * the last place, of a {@code float} value is the positive
1464      * distance between this floating-point value and the {@code
1465      * float} value next larger in magnitude.  Note that for non-NaN
1466      * <i>x</i>, <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
1467      *
1468      * <p>Special Cases:
1469      * <ul>
1470      * <li> If the argument is NaN, then the result is NaN.
1471      * <li> If the argument is positive or negative infinity, then the
1472      * result is positive infinity.
1473      * <li> If the argument is positive or negative zero, then the result is
1474      * {@code Float.MIN_VALUE}.
1475      * <li> If the argument is &plusmn;{@code Float.MAX_VALUE}, then
1476      * the result is equal to 2<sup>104</sup>.
1477      * </ul>
1478      *
1479      * @param f the floating-point value whose ulp is to be returned
1480      * @return the size of an ulp of the argument
1481      * @author Joseph D. Darcy
1482      * @since 1.5
1483      */
1484     public static float ulp(float f) {
1485         return Math.ulp(f);
1486     }
1487 
1488     /**
1489      * Returns the signum function of the argument; zero if the argument
1490      * is zero, 1.0 if the argument is greater than zero, -1.0 if the
1491      * argument is less than zero.
1492      *
1493      * <p>Special Cases:
1494      * <ul>
1495      * <li> If the argument is NaN, then the result is NaN.
1496      * <li> If the argument is positive zero or negative zero, then the
1497      *      result is the same as the argument.
1498      * </ul>
1499      *
1500      * @param d the floating-point value whose signum is to be returned
1501      * @return the signum function of the argument
1502      * @author Joseph D. Darcy
1503      * @since 1.5
1504      */
1505     public static double signum(double d) {
1506         return Math.signum(d);
1507     }
1508 
1509     /**
1510      * Returns the signum function of the argument; zero if the argument
1511      * is zero, 1.0f if the argument is greater than zero, -1.0f if the
1512      * argument is less than zero.
1513      *
1514      * <p>Special Cases:
1515      * <ul>
1516      * <li> If the argument is NaN, then the result is NaN.
1517      * <li> If the argument is positive zero or negative zero, then the
1518      *      result is the same as the argument.
1519      * </ul>
1520      *
1521      * @param f the floating-point value whose signum is to be returned
1522      * @return the signum function of the argument
1523      * @author Joseph D. Darcy
1524      * @since 1.5
1525      */
1526     public static float signum(float f) {
1527         return Math.signum(f);
1528     }
1529 
1530     /**
1531      * Returns the hyperbolic sine of a {@code double} value.
1532      * The hyperbolic sine of <i>x</i> is defined to be
1533      * (<i>e<sup>x</sup>&nbsp;-&nbsp;e<sup>-x</sup></i>)/2
1534      * where <i>e</i> is {@linkplain Math#E Euler's number}.
1535      *
1536      * <p>Special cases:
1537      * <ul>
1538      *
1539      * <li>If the argument is NaN, then the result is NaN.
1540      *
1541      * <li>If the argument is infinite, then the result is an infinity
1542      * with the same sign as the argument.
1543      *
1544      * <li>If the argument is zero, then the result is a zero with the
1545      * same sign as the argument.
1546      *
1547      * </ul>
1548      *
1549      * @param   x The number whose hyperbolic sine is to be returned.
1550      * @return  The hyperbolic sine of {@code x}.
1551      * @since 1.5
1552      */
1553     public static native double sinh(double x);
1554 
1555     /**
1556      * Returns the hyperbolic cosine of a {@code double} value.
1557      * The hyperbolic cosine of <i>x</i> is defined to be
1558      * (<i>e<sup>x</sup>&nbsp;+&nbsp;e<sup>-x</sup></i>)/2
1559      * where <i>e</i> is {@linkplain Math#E Euler's number}.
1560      *
1561      * <p>Special cases:
1562      * <ul>
1563      *
1564      * <li>If the argument is NaN, then the result is NaN.
1565      *
1566      * <li>If the argument is infinite, then the result is positive
1567      * infinity.
1568      *
1569      * <li>If the argument is zero, then the result is {@code 1.0}.
1570      *
1571      * </ul>
1572      *
1573      * @param   x The number whose hyperbolic cosine is to be returned.
1574      * @return  The hyperbolic cosine of {@code x}.
1575      * @since 1.5
1576      */
1577     public static native double cosh(double x);
1578 
1579     /**
1580      * Returns the hyperbolic tangent of a {@code double} value.
1581      * The hyperbolic tangent of <i>x</i> is defined to be
1582      * (<i>e<sup>x</sup>&nbsp;-&nbsp;e<sup>-x</sup></i>)/(<i>e<sup>x</sup>&nbsp;+&nbsp;e<sup>-x</sup></i>),
1583      * in other words, {@linkplain Math#sinh
1584      * sinh(<i>x</i>)}/{@linkplain Math#cosh cosh(<i>x</i>)}.  Note
1585      * that the absolute value of the exact tanh is always less than
1586      * 1.
1587      *
1588      * <p>Special cases:
1589      * <ul>
1590      *
1591      * <li>If the argument is NaN, then the result is NaN.
1592      *
1593      * <li>If the argument is zero, then the result is a zero with the
1594      * same sign as the argument.
1595      *
1596      * <li>If the argument is positive infinity, then the result is
1597      * {@code +1.0}.
1598      *
1599      * <li>If the argument is negative infinity, then the result is
1600      * {@code -1.0}.
1601      *
1602      * </ul>
1603      *
1604      * @param   x The number whose hyperbolic tangent is to be returned.
1605      * @return  The hyperbolic tangent of {@code x}.
1606      * @since 1.5
1607      */
1608     public static native double tanh(double x);
1609 
1610     /**
1611      * Returns sqrt(<i>x</i><sup>2</sup>&nbsp;+<i>y</i><sup>2</sup>)
1612      * without intermediate overflow or underflow.
1613      *
1614      * <p>Special cases:
1615      * <ul>
1616      *
1617      * <li> If either argument is infinite, then the result
1618      * is positive infinity.
1619      *
1620      * <li> If either argument is NaN and neither argument is infinite,
1621      * then the result is NaN.
1622      *
1623      * </ul>
1624      *
1625      * @param x a value
1626      * @param y a value
1627      * @return sqrt(<i>x</i><sup>2</sup>&nbsp;+<i>y</i><sup>2</sup>)
1628      * without intermediate overflow or underflow
1629      * @since 1.5
1630      */
1631     public static double hypot(double x, double y) {
1632         return FdLibm.Hypot.compute(x, y);
1633     }
1634 
1635     /**
1636      * Returns <i>e</i><sup>x</sup>&nbsp;-1.  Note that for values of
1637      * <i>x</i> near 0, the exact sum of
1638      * {@code expm1(x)}&nbsp;+&nbsp;1 is much closer to the true
1639      * result of <i>e</i><sup>x</sup> than {@code exp(x)}.
1640      *
1641      * <p>Special cases:
1642      * <ul>
1643      * <li>If the argument is NaN, the result is NaN.
1644      *
1645      * <li>If the argument is positive infinity, then the result is
1646      * positive infinity.
1647      *
1648      * <li>If the argument is negative infinity, then the result is
1649      * -1.0.
1650      *
1651      * <li>If the argument is zero, then the result is a zero with the
1652      * same sign as the argument.
1653      *
1654      * </ul>
1655      *
1656      * @param   x   the exponent to raise <i>e</i> to in the computation of
1657      *              <i>e</i><sup>{@code x}</sup>&nbsp;-1.
1658      * @return  the value <i>e</i><sup>{@code x}</sup>&nbsp;-&nbsp;1.
1659      * @since 1.5
1660      */
1661     public static native double expm1(double x);
1662 
1663     /**
1664      * Returns the natural logarithm of the sum of the argument and 1.
1665      * Note that for small values {@code x}, the result of
1666      * {@code log1p(x)} is much closer to the true result of ln(1
1667      * + {@code x}) than the floating-point evaluation of
1668      * {@code log(1.0+x)}.
1669      *
1670      * <p>Special cases:
1671      * <ul>
1672      *
1673      * <li>If the argument is NaN or less than -1, then the result is
1674      * NaN.
1675      *
1676      * <li>If the argument is positive infinity, then the result is
1677      * positive infinity.
1678      *
1679      * <li>If the argument is negative one, then the result is
1680      * negative infinity.
1681      *
1682      * <li>If the argument is zero, then the result is a zero with the
1683      * same sign as the argument.
1684      *
1685      * </ul>
1686      *
1687      * @param   x   a value
1688      * @return the value ln({@code x}&nbsp;+&nbsp;1), the natural
1689      * log of {@code x}&nbsp;+&nbsp;1
1690      * @since 1.5
1691      */
1692     public static native double log1p(double x);
1693 
1694     /**
1695      * Returns the first floating-point argument with the sign of the
1696      * second floating-point argument.  For this method, a NaN
1697      * {@code sign} argument is always treated as if it were
1698      * positive.
1699      *
1700      * @param magnitude  the parameter providing the magnitude of the result
1701      * @param sign   the parameter providing the sign of the result
1702      * @return a value with the magnitude of {@code magnitude}
1703      * and the sign of {@code sign}.
1704      * @since 1.6
1705      */
1706     public static double copySign(double magnitude, double sign) {
1707         return Math.copySign(magnitude, (Double.isNaN(sign)?1.0d:sign));
1708     }
1709 
1710     /**
1711      * Returns the first floating-point argument with the sign of the
1712      * second floating-point argument.  For this method, a NaN
1713      * {@code sign} argument is always treated as if it were
1714      * positive.
1715      *
1716      * @param magnitude  the parameter providing the magnitude of the result
1717      * @param sign   the parameter providing the sign of the result
1718      * @return a value with the magnitude of {@code magnitude}
1719      * and the sign of {@code sign}.
1720      * @since 1.6
1721      */
1722     public static float copySign(float magnitude, float sign) {
1723         return Math.copySign(magnitude, (Float.isNaN(sign)?1.0f:sign));
1724     }
1725     /**
1726      * Returns the unbiased exponent used in the representation of a
1727      * {@code float}.  Special cases:
1728      *
1729      * <ul>
1730      * <li>If the argument is NaN or infinite, then the result is
1731      * {@link Float#MAX_EXPONENT} + 1.
1732      * <li>If the argument is zero or subnormal, then the result is
1733      * {@link Float#MIN_EXPONENT} -1.
1734      * </ul>
1735      * @param f a {@code float} value
1736      * @return the unbiased exponent of the argument
1737      * @since 1.6
1738      */
1739     public static int getExponent(float f) {
1740         return Math.getExponent(f);
1741     }
1742 
1743     /**
1744      * Returns the unbiased exponent used in the representation of a
1745      * {@code double}.  Special cases:
1746      *
1747      * <ul>
1748      * <li>If the argument is NaN or infinite, then the result is
1749      * {@link Double#MAX_EXPONENT} + 1.
1750      * <li>If the argument is zero or subnormal, then the result is
1751      * {@link Double#MIN_EXPONENT} -1.
1752      * </ul>
1753      * @param d a {@code double} value
1754      * @return the unbiased exponent of the argument
1755      * @since 1.6
1756      */
1757     public static int getExponent(double d) {
1758         return Math.getExponent(d);
1759     }
1760 
1761     /**
1762      * Returns the floating-point number adjacent to the first
1763      * argument in the direction of the second argument.  If both
1764      * arguments compare as equal the second argument is returned.
1765      *
1766      * <p>Special cases:
1767      * <ul>
1768      * <li> If either argument is a NaN, then NaN is returned.
1769      *
1770      * <li> If both arguments are signed zeros, {@code direction}
1771      * is returned unchanged (as implied by the requirement of
1772      * returning the second argument if the arguments compare as
1773      * equal).
1774      *
1775      * <li> If {@code start} is
1776      * &plusmn;{@link Double#MIN_VALUE} and {@code direction}
1777      * has a value such that the result should have a smaller
1778      * magnitude, then a zero with the same sign as {@code start}
1779      * is returned.
1780      *
1781      * <li> If {@code start} is infinite and
1782      * {@code direction} has a value such that the result should
1783      * have a smaller magnitude, {@link Double#MAX_VALUE} with the
1784      * same sign as {@code start} is returned.
1785      *
1786      * <li> If {@code start} is equal to &plusmn;
1787      * {@link Double#MAX_VALUE} and {@code direction} has a
1788      * value such that the result should have a larger magnitude, an
1789      * infinity with same sign as {@code start} is returned.
1790      * </ul>
1791      *
1792      * @param start  starting floating-point value
1793      * @param direction value indicating which of
1794      * {@code start}'s neighbors or {@code start} should
1795      * be returned
1796      * @return The floating-point number adjacent to {@code start} in the
1797      * direction of {@code direction}.
1798      * @since 1.6
1799      */
1800     public static double nextAfter(double start, double direction) {
1801         return Math.nextAfter(start, direction);
1802     }
1803 
1804     /**
1805      * Returns the floating-point number adjacent to the first
1806      * argument in the direction of the second argument.  If both
1807      * arguments compare as equal a value equivalent to the second argument
1808      * is returned.
1809      *
1810      * <p>Special cases:
1811      * <ul>
1812      * <li> If either argument is a NaN, then NaN is returned.
1813      *
1814      * <li> If both arguments are signed zeros, a value equivalent
1815      * to {@code direction} is returned.
1816      *
1817      * <li> If {@code start} is
1818      * &plusmn;{@link Float#MIN_VALUE} and {@code direction}
1819      * has a value such that the result should have a smaller
1820      * magnitude, then a zero with the same sign as {@code start}
1821      * is returned.
1822      *
1823      * <li> If {@code start} is infinite and
1824      * {@code direction} has a value such that the result should
1825      * have a smaller magnitude, {@link Float#MAX_VALUE} with the
1826      * same sign as {@code start} is returned.
1827      *
1828      * <li> If {@code start} is equal to &plusmn;
1829      * {@link Float#MAX_VALUE} and {@code direction} has a
1830      * value such that the result should have a larger magnitude, an
1831      * infinity with same sign as {@code start} is returned.
1832      * </ul>
1833      *
1834      * @param start  starting floating-point value
1835      * @param direction value indicating which of
1836      * {@code start}'s neighbors or {@code start} should
1837      * be returned
1838      * @return The floating-point number adjacent to {@code start} in the
1839      * direction of {@code direction}.
1840      * @since 1.6
1841      */
1842     public static float nextAfter(float start, double direction) {
1843         return Math.nextAfter(start, direction);
1844     }
1845 
1846     /**
1847      * Returns the floating-point value adjacent to {@code d} in
1848      * the direction of positive infinity.  This method is
1849      * semantically equivalent to {@code nextAfter(d,
1850      * Double.POSITIVE_INFINITY)}; however, a {@code nextUp}
1851      * implementation may run faster than its equivalent
1852      * {@code nextAfter} call.
1853      *
1854      * <p>Special Cases:
1855      * <ul>
1856      * <li> If the argument is NaN, the result is NaN.
1857      *
1858      * <li> If the argument is positive infinity, the result is
1859      * positive infinity.
1860      *
1861      * <li> If the argument is zero, the result is
1862      * {@link Double#MIN_VALUE}
1863      *
1864      * </ul>
1865      *
1866      * @param d starting floating-point value
1867      * @return The adjacent floating-point value closer to positive
1868      * infinity.
1869      * @since 1.6
1870      */
1871     public static double nextUp(double d) {
1872         return Math.nextUp(d);
1873     }
1874 
1875     /**
1876      * Returns the floating-point value adjacent to {@code f} in
1877      * the direction of positive infinity.  This method is
1878      * semantically equivalent to {@code nextAfter(f,
1879      * Float.POSITIVE_INFINITY)}; however, a {@code nextUp}
1880      * implementation may run faster than its equivalent
1881      * {@code nextAfter} call.
1882      *
1883      * <p>Special Cases:
1884      * <ul>
1885      * <li> If the argument is NaN, the result is NaN.
1886      *
1887      * <li> If the argument is positive infinity, the result is
1888      * positive infinity.
1889      *
1890      * <li> If the argument is zero, the result is
1891      * {@link Float#MIN_VALUE}
1892      *
1893      * </ul>
1894      *
1895      * @param f starting floating-point value
1896      * @return The adjacent floating-point value closer to positive
1897      * infinity.
1898      * @since 1.6
1899      */
1900     public static float nextUp(float f) {
1901         return Math.nextUp(f);
1902     }
1903 
1904     /**
1905      * Returns the floating-point value adjacent to {@code d} in
1906      * the direction of negative infinity.  This method is
1907      * semantically equivalent to {@code nextAfter(d,
1908      * Double.NEGATIVE_INFINITY)}; however, a
1909      * {@code nextDown} implementation may run faster than its
1910      * equivalent {@code nextAfter} call.
1911      *
1912      * <p>Special Cases:
1913      * <ul>
1914      * <li> If the argument is NaN, the result is NaN.
1915      *
1916      * <li> If the argument is negative infinity, the result is
1917      * negative infinity.
1918      *
1919      * <li> If the argument is zero, the result is
1920      * {@code -Double.MIN_VALUE}
1921      *
1922      * </ul>
1923      *
1924      * @param d  starting floating-point value
1925      * @return The adjacent floating-point value closer to negative
1926      * infinity.
1927      * @since 1.8
1928      */
1929     public static double nextDown(double d) {
1930         return Math.nextDown(d);
1931     }
1932 
1933     /**
1934      * Returns the floating-point value adjacent to {@code f} in
1935      * the direction of negative infinity.  This method is
1936      * semantically equivalent to {@code nextAfter(f,
1937      * Float.NEGATIVE_INFINITY)}; however, a
1938      * {@code nextDown} implementation may run faster than its
1939      * equivalent {@code nextAfter} call.
1940      *
1941      * <p>Special Cases:
1942      * <ul>
1943      * <li> If the argument is NaN, the result is NaN.
1944      *
1945      * <li> If the argument is negative infinity, the result is
1946      * negative infinity.
1947      *
1948      * <li> If the argument is zero, the result is
1949      * {@code -Float.MIN_VALUE}
1950      *
1951      * </ul>
1952      *
1953      * @param f  starting floating-point value
1954      * @return The adjacent floating-point value closer to negative
1955      * infinity.
1956      * @since 1.8
1957      */
1958     public static float nextDown(float f) {
1959         return Math.nextDown(f);
1960     }
1961 
1962     /**
1963      * Returns {@code d} &times;
1964      * 2<sup>{@code scaleFactor}</sup> rounded as if performed
1965      * by a single correctly rounded floating-point multiply to a
1966      * member of the double value set.  See the Java
1967      * Language Specification for a discussion of floating-point
1968      * value sets.  If the exponent of the result is between {@link
1969      * Double#MIN_EXPONENT} and {@link Double#MAX_EXPONENT}, the
1970      * answer is calculated exactly.  If the exponent of the result
1971      * would be larger than {@code Double.MAX_EXPONENT}, an
1972      * infinity is returned.  Note that if the result is subnormal,
1973      * precision may be lost; that is, when {@code scalb(x, n)}
1974      * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
1975      * <i>x</i>.  When the result is non-NaN, the result has the same
1976      * sign as {@code d}.
1977      *
1978      * <p>Special cases:
1979      * <ul>
1980      * <li> If the first argument is NaN, NaN is returned.
1981      * <li> If the first argument is infinite, then an infinity of the
1982      * same sign is returned.
1983      * <li> If the first argument is zero, then a zero of the same
1984      * sign is returned.
1985      * </ul>
1986      *
1987      * @param d number to be scaled by a power of two.
1988      * @param scaleFactor power of 2 used to scale {@code d}
1989      * @return {@code d} &times; 2<sup>{@code scaleFactor}</sup>
1990      * @since 1.6
1991      */
1992     public static double scalb(double d, int scaleFactor) {
1993         return Math.scalb(d, scaleFactor);
1994     }
1995 
1996     /**
1997      * Returns {@code f} &times;
1998      * 2<sup>{@code scaleFactor}</sup> rounded as if performed
1999      * by a single correctly rounded floating-point multiply to a
2000      * member of the float value set.  See the Java
2001      * Language Specification for a discussion of floating-point
2002      * value sets.  If the exponent of the result is between {@link
2003      * Float#MIN_EXPONENT} and {@link Float#MAX_EXPONENT}, the
2004      * answer is calculated exactly.  If the exponent of the result
2005      * would be larger than {@code Float.MAX_EXPONENT}, an
2006      * infinity is returned.  Note that if the result is subnormal,
2007      * precision may be lost; that is, when {@code scalb(x, n)}
2008      * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
2009      * <i>x</i>.  When the result is non-NaN, the result has the same
2010      * sign as {@code f}.
2011      *
2012      * <p>Special cases:
2013      * <ul>
2014      * <li> If the first argument is NaN, NaN is returned.
2015      * <li> If the first argument is infinite, then an infinity of the
2016      * same sign is returned.
2017      * <li> If the first argument is zero, then a zero of the same
2018      * sign is returned.
2019      * </ul>
2020      *
2021      * @param f number to be scaled by a power of two.
2022      * @param scaleFactor power of 2 used to scale {@code f}
2023      * @return {@code f} &times; 2<sup>{@code scaleFactor}</sup>
2024      * @since 1.6
2025      */
2026     public static float scalb(float f, int scaleFactor) {
2027         return Math.scalb(f, scaleFactor);
2028     }
2029 }
--- EOF ---