1.1 --- a/emul/src/main/java/java/lang/StrictMath.java Tue Oct 30 22:59:31 2012 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,1457 +0,0 @@
1.4 -/*
1.5 - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1.7 - *
1.8 - * This code is free software; you can redistribute it and/or modify it
1.9 - * under the terms of the GNU General Public License version 2 only, as
1.10 - * published by the Free Software Foundation. Oracle designates this
1.11 - * particular file as subject to the "Classpath" exception as provided
1.12 - * by Oracle in the LICENSE file that accompanied this code.
1.13 - *
1.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
1.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1.17 - * version 2 for more details (a copy is included in the LICENSE file that
1.18 - * accompanied this code).
1.19 - *
1.20 - * You should have received a copy of the GNU General Public License version
1.21 - * 2 along with this work; if not, write to the Free Software Foundation,
1.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1.23 - *
1.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1.25 - * or visit www.oracle.com if you need additional information or have any
1.26 - * questions.
1.27 - */
1.28 -
1.29 -package java.lang;
1.30 -
1.31 -/**
1.32 - * The class {@code StrictMath} contains methods for performing basic
1.33 - * numeric operations such as the elementary exponential, logarithm,
1.34 - * square root, and trigonometric functions.
1.35 - *
1.36 - * <p>To help ensure portability of Java programs, the definitions of
1.37 - * some of the numeric functions in this package require that they
1.38 - * produce the same results as certain published algorithms. These
1.39 - * algorithms are available from the well-known network library
1.40 - * {@code netlib} as the package "Freely Distributable Math
1.41 - * Library," <a
1.42 - * href="ftp://ftp.netlib.org/fdlibm.tar">{@code fdlibm}</a>. These
1.43 - * algorithms, which are written in the C programming language, are
1.44 - * then to be understood as executed with all floating-point
1.45 - * operations following the rules of Java floating-point arithmetic.
1.46 - *
1.47 - * <p>The Java math library is defined with respect to
1.48 - * {@code fdlibm} version 5.3. Where {@code fdlibm} provides
1.49 - * more than one definition for a function (such as
1.50 - * {@code acos}), use the "IEEE 754 core function" version
1.51 - * (residing in a file whose name begins with the letter
1.52 - * {@code e}). The methods which require {@code fdlibm}
1.53 - * semantics are {@code sin}, {@code cos}, {@code tan},
1.54 - * {@code asin}, {@code acos}, {@code atan},
1.55 - * {@code exp}, {@code log}, {@code log10},
1.56 - * {@code cbrt}, {@code atan2}, {@code pow},
1.57 - * {@code sinh}, {@code cosh}, {@code tanh},
1.58 - * {@code hypot}, {@code expm1}, and {@code log1p}.
1.59 - *
1.60 - * @author unascribed
1.61 - * @author Joseph D. Darcy
1.62 - * @since 1.3
1.63 - */
1.64 -
1.65 -public final class StrictMath {
1.66 -
1.67 - /**
1.68 - * Don't let anyone instantiate this class.
1.69 - */
1.70 - private StrictMath() {}
1.71 -
1.72 - /**
1.73 - * The {@code double} value that is closer than any other to
1.74 - * <i>e</i>, the base of the natural logarithms.
1.75 - */
1.76 - public static final double E = 2.7182818284590452354;
1.77 -
1.78 - /**
1.79 - * The {@code double} value that is closer than any other to
1.80 - * <i>pi</i>, the ratio of the circumference of a circle to its
1.81 - * diameter.
1.82 - */
1.83 - public static final double PI = 3.14159265358979323846;
1.84 -
1.85 - /**
1.86 - * Returns the trigonometric sine of an angle. Special cases:
1.87 - * <ul><li>If the argument is NaN or an infinity, then the
1.88 - * result is NaN.
1.89 - * <li>If the argument is zero, then the result is a zero with the
1.90 - * same sign as the argument.</ul>
1.91 - *
1.92 - * @param a an angle, in radians.
1.93 - * @return the sine of the argument.
1.94 - */
1.95 - public static native double sin(double a);
1.96 -
1.97 - /**
1.98 - * Returns the trigonometric cosine of an angle. Special cases:
1.99 - * <ul><li>If the argument is NaN or an infinity, then the
1.100 - * result is NaN.</ul>
1.101 - *
1.102 - * @param a an angle, in radians.
1.103 - * @return the cosine of the argument.
1.104 - */
1.105 - public static native double cos(double a);
1.106 -
1.107 - /**
1.108 - * Returns the trigonometric tangent of an angle. Special cases:
1.109 - * <ul><li>If the argument is NaN or an infinity, then the result
1.110 - * is NaN.
1.111 - * <li>If the argument is zero, then the result is a zero with the
1.112 - * same sign as the argument.</ul>
1.113 - *
1.114 - * @param a an angle, in radians.
1.115 - * @return the tangent of the argument.
1.116 - */
1.117 - public static native double tan(double a);
1.118 -
1.119 - /**
1.120 - * Returns the arc sine of a value; the returned angle is in the
1.121 - * range -<i>pi</i>/2 through <i>pi</i>/2. Special cases:
1.122 - * <ul><li>If the argument is NaN or its absolute value is greater
1.123 - * than 1, then the result is NaN.
1.124 - * <li>If the argument is zero, then the result is a zero with the
1.125 - * same sign as the argument.</ul>
1.126 - *
1.127 - * @param a the value whose arc sine is to be returned.
1.128 - * @return the arc sine of the argument.
1.129 - */
1.130 - public static native double asin(double a);
1.131 -
1.132 - /**
1.133 - * Returns the arc cosine of a value; the returned angle is in the
1.134 - * range 0.0 through <i>pi</i>. Special case:
1.135 - * <ul><li>If the argument is NaN or its absolute value is greater
1.136 - * than 1, then the result is NaN.</ul>
1.137 - *
1.138 - * @param a the value whose arc cosine is to be returned.
1.139 - * @return the arc cosine of the argument.
1.140 - */
1.141 - public static native double acos(double a);
1.142 -
1.143 - /**
1.144 - * Returns the arc tangent of a value; the returned angle is in the
1.145 - * range -<i>pi</i>/2 through <i>pi</i>/2. Special cases:
1.146 - * <ul><li>If the argument is NaN, then the result is NaN.
1.147 - * <li>If the argument is zero, then the result is a zero with the
1.148 - * same sign as the argument.</ul>
1.149 - *
1.150 - * @param a the value whose arc tangent is to be returned.
1.151 - * @return the arc tangent of the argument.
1.152 - */
1.153 - public static native double atan(double a);
1.154 -
1.155 - /**
1.156 - * Converts an angle measured in degrees to an approximately
1.157 - * equivalent angle measured in radians. The conversion from
1.158 - * degrees to radians is generally inexact.
1.159 - *
1.160 - * @param angdeg an angle, in degrees
1.161 - * @return the measurement of the angle {@code angdeg}
1.162 - * in radians.
1.163 - */
1.164 - public static strictfp double toRadians(double angdeg) {
1.165 - return angdeg / 180.0 * PI;
1.166 - }
1.167 -
1.168 - /**
1.169 - * Converts an angle measured in radians to an approximately
1.170 - * equivalent angle measured in degrees. The conversion from
1.171 - * radians to degrees is generally inexact; users should
1.172 - * <i>not</i> expect {@code cos(toRadians(90.0))} to exactly
1.173 - * equal {@code 0.0}.
1.174 - *
1.175 - * @param angrad an angle, in radians
1.176 - * @return the measurement of the angle {@code angrad}
1.177 - * in degrees.
1.178 - */
1.179 - public static strictfp double toDegrees(double angrad) {
1.180 - return angrad * 180.0 / PI;
1.181 - }
1.182 -
1.183 - /**
1.184 - * Returns Euler's number <i>e</i> raised to the power of a
1.185 - * {@code double} value. Special cases:
1.186 - * <ul><li>If the argument is NaN, the result is NaN.
1.187 - * <li>If the argument is positive infinity, then the result is
1.188 - * positive infinity.
1.189 - * <li>If the argument is negative infinity, then the result is
1.190 - * positive zero.</ul>
1.191 - *
1.192 - * @param a the exponent to raise <i>e</i> to.
1.193 - * @return the value <i>e</i><sup>{@code a}</sup>,
1.194 - * where <i>e</i> is the base of the natural logarithms.
1.195 - */
1.196 - public static native double exp(double a);
1.197 -
1.198 - /**
1.199 - * Returns the natural logarithm (base <i>e</i>) of a {@code double}
1.200 - * value. Special cases:
1.201 - * <ul><li>If the argument is NaN or less than zero, then the result
1.202 - * is NaN.
1.203 - * <li>If the argument is positive infinity, then the result is
1.204 - * positive infinity.
1.205 - * <li>If the argument is positive zero or negative zero, then the
1.206 - * result is negative infinity.</ul>
1.207 - *
1.208 - * @param a a value
1.209 - * @return the value ln {@code a}, the natural logarithm of
1.210 - * {@code a}.
1.211 - */
1.212 - public static native double log(double a);
1.213 -
1.214 -
1.215 - /**
1.216 - * Returns the base 10 logarithm of a {@code double} value.
1.217 - * Special cases:
1.218 - *
1.219 - * <ul><li>If the argument is NaN or less than zero, then the result
1.220 - * is NaN.
1.221 - * <li>If the argument is positive infinity, then the result is
1.222 - * positive infinity.
1.223 - * <li>If the argument is positive zero or negative zero, then the
1.224 - * result is negative infinity.
1.225 - * <li> If the argument is equal to 10<sup><i>n</i></sup> for
1.226 - * integer <i>n</i>, then the result is <i>n</i>.
1.227 - * </ul>
1.228 - *
1.229 - * @param a a value
1.230 - * @return the base 10 logarithm of {@code a}.
1.231 - * @since 1.5
1.232 - */
1.233 - public static native double log10(double a);
1.234 -
1.235 - /**
1.236 - * Returns the correctly rounded positive square root of a
1.237 - * {@code double} value.
1.238 - * Special cases:
1.239 - * <ul><li>If the argument is NaN or less than zero, then the result
1.240 - * is NaN.
1.241 - * <li>If the argument is positive infinity, then the result is positive
1.242 - * infinity.
1.243 - * <li>If the argument is positive zero or negative zero, then the
1.244 - * result is the same as the argument.</ul>
1.245 - * Otherwise, the result is the {@code double} value closest to
1.246 - * the true mathematical square root of the argument value.
1.247 - *
1.248 - * @param a a value.
1.249 - * @return the positive square root of {@code a}.
1.250 - */
1.251 - public static native double sqrt(double a);
1.252 -
1.253 - /**
1.254 - * Returns the cube root of a {@code double} value. For
1.255 - * positive finite {@code x}, {@code cbrt(-x) ==
1.256 - * -cbrt(x)}; that is, the cube root of a negative value is
1.257 - * the negative of the cube root of that value's magnitude.
1.258 - * Special cases:
1.259 - *
1.260 - * <ul>
1.261 - *
1.262 - * <li>If the argument is NaN, then the result is NaN.
1.263 - *
1.264 - * <li>If the argument is infinite, then the result is an infinity
1.265 - * with the same sign as the argument.
1.266 - *
1.267 - * <li>If the argument is zero, then the result is a zero with the
1.268 - * same sign as the argument.
1.269 - *
1.270 - * </ul>
1.271 - *
1.272 - * @param a a value.
1.273 - * @return the cube root of {@code a}.
1.274 - * @since 1.5
1.275 - */
1.276 - public static native double cbrt(double a);
1.277 -
1.278 - /**
1.279 - * Computes the remainder operation on two arguments as prescribed
1.280 - * by the IEEE 754 standard.
1.281 - * The remainder value is mathematically equal to
1.282 - * <code>f1 - f2</code> × <i>n</i>,
1.283 - * where <i>n</i> is the mathematical integer closest to the exact
1.284 - * mathematical value of the quotient {@code f1/f2}, and if two
1.285 - * mathematical integers are equally close to {@code f1/f2},
1.286 - * then <i>n</i> is the integer that is even. If the remainder is
1.287 - * zero, its sign is the same as the sign of the first argument.
1.288 - * Special cases:
1.289 - * <ul><li>If either argument is NaN, or the first argument is infinite,
1.290 - * or the second argument is positive zero or negative zero, then the
1.291 - * result is NaN.
1.292 - * <li>If the first argument is finite and the second argument is
1.293 - * infinite, then the result is the same as the first argument.</ul>
1.294 - *
1.295 - * @param f1 the dividend.
1.296 - * @param f2 the divisor.
1.297 - * @return the remainder when {@code f1} is divided by
1.298 - * {@code f2}.
1.299 - */
1.300 - public static native double IEEEremainder(double f1, double f2);
1.301 -
1.302 - /**
1.303 - * Returns the smallest (closest to negative infinity)
1.304 - * {@code double} value that is greater than or equal to the
1.305 - * argument and is equal to a mathematical integer. Special cases:
1.306 - * <ul><li>If the argument value is already equal to a
1.307 - * mathematical integer, then the result is the same as the
1.308 - * argument. <li>If the argument is NaN or an infinity or
1.309 - * positive zero or negative zero, then the result is the same as
1.310 - * the argument. <li>If the argument value is less than zero but
1.311 - * greater than -1.0, then the result is negative zero.</ul> Note
1.312 - * that the value of {@code StrictMath.ceil(x)} is exactly the
1.313 - * value of {@code -StrictMath.floor(-x)}.
1.314 - *
1.315 - * @param a a value.
1.316 - * @return the smallest (closest to negative infinity)
1.317 - * floating-point value that is greater than or equal to
1.318 - * the argument and is equal to a mathematical integer.
1.319 - */
1.320 - public static double ceil(double a) {
1.321 - return floorOrCeil(a, -0.0, 1.0, 1.0);
1.322 - }
1.323 -
1.324 - /**
1.325 - * Returns the largest (closest to positive infinity)
1.326 - * {@code double} value that is less than or equal to the
1.327 - * argument and is equal to a mathematical integer. Special cases:
1.328 - * <ul><li>If the argument value is already equal to a
1.329 - * mathematical integer, then the result is the same as the
1.330 - * argument. <li>If the argument is NaN or an infinity or
1.331 - * positive zero or negative zero, then the result is the same as
1.332 - * the argument.</ul>
1.333 - *
1.334 - * @param a a value.
1.335 - * @return the largest (closest to positive infinity)
1.336 - * floating-point value that less than or equal to the argument
1.337 - * and is equal to a mathematical integer.
1.338 - */
1.339 - public static double floor(double a) {
1.340 - return floorOrCeil(a, -1.0, 0.0, -1.0);
1.341 - }
1.342 -
1.343 - /**
1.344 - * Internal method to share logic between floor and ceil.
1.345 - *
1.346 - * @param a the value to be floored or ceiled
1.347 - * @param negativeBoundary result for values in (-1, 0)
1.348 - * @param positiveBoundary result for values in (0, 1)
1.349 - * @param increment value to add when the argument is non-integral
1.350 - */
1.351 - private static double floorOrCeil(double a,
1.352 - double negativeBoundary,
1.353 - double positiveBoundary,
1.354 - double sign) {
1.355 - int exponent = getExponent(a);
1.356 -
1.357 - if (exponent < 0) {
1.358 - /*
1.359 - * Absolute value of argument is less than 1.
1.360 - * floorOrceil(-0.0) => -0.0
1.361 - * floorOrceil(+0.0) => +0.0
1.362 - */
1.363 - return ((a == 0.0) ? a :
1.364 - ( (a < 0.0) ? negativeBoundary : positiveBoundary) );
1.365 - } else if (exponent >= 52) {
1.366 - /*
1.367 - * Infinity, NaN, or a value so large it must be integral.
1.368 - */
1.369 - return a;
1.370 - }
1.371 - // Else the argument is either an integral value already XOR it
1.372 - // has to be rounded to one.
1.373 - assert exponent >= 0 && exponent <= 51;
1.374 -
1.375 - long doppel = Double.doubleToRawLongBits(a);
1.376 - long mask = 0; // DoubleConsts.SIGNIF_BIT_MASK >> exponent;
1.377 -
1.378 - if ( (mask & doppel) == 0L )
1.379 - return a; // integral value
1.380 - else {
1.381 - double result = Double.longBitsToDouble(doppel & (~mask));
1.382 - if (sign*a > 0.0)
1.383 - result = result + sign;
1.384 - return result;
1.385 - }
1.386 - }
1.387 -
1.388 - /**
1.389 - * Returns the {@code double} value that is closest in value
1.390 - * to the argument and is equal to a mathematical integer. If two
1.391 - * {@code double} values that are mathematical integers are
1.392 - * equally close to the value of the argument, the result is the
1.393 - * integer value that is even. Special cases:
1.394 - * <ul><li>If the argument value is already equal to a mathematical
1.395 - * integer, then the result is the same as the argument.
1.396 - * <li>If the argument is NaN or an infinity or positive zero or negative
1.397 - * zero, then the result is the same as the argument.</ul>
1.398 - *
1.399 - * @param a a value.
1.400 - * @return the closest floating-point value to {@code a} that is
1.401 - * equal to a mathematical integer.
1.402 - * @author Joseph D. Darcy
1.403 - */
1.404 - public static double rint(double a) {
1.405 - throw new UnsupportedOperationException();
1.406 - /*
1.407 - * If the absolute value of a is not less than 2^52, it
1.408 - * is either a finite integer (the double format does not have
1.409 - * enough significand bits for a number that large to have any
1.410 - * fractional portion), an infinity, or a NaN. In any of
1.411 - * these cases, rint of the argument is the argument.
1.412 - *
1.413 - * Otherwise, the sum (twoToThe52 + a ) will properly round
1.414 - * away any fractional portion of a since ulp(twoToThe52) ==
1.415 - * 1.0; subtracting out twoToThe52 from this sum will then be
1.416 - * exact and leave the rounded integer portion of a.
1.417 - *
1.418 - * This method does *not* need to be declared strictfp to get
1.419 - * fully reproducible results. Whether or not a method is
1.420 - * declared strictfp can only make a difference in the
1.421 - * returned result if some operation would overflow or
1.422 - * underflow with strictfp semantics. The operation
1.423 - * (twoToThe52 + a ) cannot overflow since large values of a
1.424 - * are screened out; the add cannot underflow since twoToThe52
1.425 - * is too large. The subtraction ((twoToThe52 + a ) -
1.426 - * twoToThe52) will be exact as discussed above and thus
1.427 - * cannot overflow or meaningfully underflow. Finally, the
1.428 - * last multiply in the return statement is by plus or minus
1.429 - * 1.0, which is exact too.
1.430 - */
1.431 -// double twoToThe52 = (double)(1L << 52); // 2^52
1.432 -// double sign = FpUtils.rawCopySign(1.0, a); // preserve sign info
1.433 -// a = Math.abs(a);
1.434 -//
1.435 -// if (a < twoToThe52) { // E_min <= ilogb(a) <= 51
1.436 -// a = ((twoToThe52 + a ) - twoToThe52);
1.437 -// }
1.438 -//
1.439 -// return sign * a; // restore original sign
1.440 - }
1.441 -
1.442 - /**
1.443 - * Returns the angle <i>theta</i> from the conversion of rectangular
1.444 - * coordinates ({@code x}, {@code y}) to polar
1.445 - * coordinates (r, <i>theta</i>).
1.446 - * This method computes the phase <i>theta</i> by computing an arc tangent
1.447 - * of {@code y/x} in the range of -<i>pi</i> to <i>pi</i>. Special
1.448 - * cases:
1.449 - * <ul><li>If either argument is NaN, then the result is NaN.
1.450 - * <li>If the first argument is positive zero and the second argument
1.451 - * is positive, or the first argument is positive and finite and the
1.452 - * second argument is positive infinity, then the result is positive
1.453 - * zero.
1.454 - * <li>If the first argument is negative zero and the second argument
1.455 - * is positive, or the first argument is negative and finite and the
1.456 - * second argument is positive infinity, then the result is negative zero.
1.457 - * <li>If the first argument is positive zero and the second argument
1.458 - * is negative, or the first argument is positive and finite and the
1.459 - * second argument is negative infinity, then the result is the
1.460 - * {@code double} value closest to <i>pi</i>.
1.461 - * <li>If the first argument is negative zero and the second argument
1.462 - * is negative, or the first argument is negative and finite and the
1.463 - * second argument is negative infinity, then the result is the
1.464 - * {@code double} value closest to -<i>pi</i>.
1.465 - * <li>If the first argument is positive and the second argument is
1.466 - * positive zero or negative zero, or the first argument is positive
1.467 - * infinity and the second argument is finite, then the result is the
1.468 - * {@code double} value closest to <i>pi</i>/2.
1.469 - * <li>If the first argument is negative and the second argument is
1.470 - * positive zero or negative zero, or the first argument is negative
1.471 - * infinity and the second argument is finite, then the result is the
1.472 - * {@code double} value closest to -<i>pi</i>/2.
1.473 - * <li>If both arguments are positive infinity, then the result is the
1.474 - * {@code double} value closest to <i>pi</i>/4.
1.475 - * <li>If the first argument is positive infinity and the second argument
1.476 - * is negative infinity, then the result is the {@code double}
1.477 - * value closest to 3*<i>pi</i>/4.
1.478 - * <li>If the first argument is negative infinity and the second argument
1.479 - * is positive infinity, then the result is the {@code double} value
1.480 - * closest to -<i>pi</i>/4.
1.481 - * <li>If both arguments are negative infinity, then the result is the
1.482 - * {@code double} value closest to -3*<i>pi</i>/4.</ul>
1.483 - *
1.484 - * @param y the ordinate coordinate
1.485 - * @param x the abscissa coordinate
1.486 - * @return the <i>theta</i> component of the point
1.487 - * (<i>r</i>, <i>theta</i>)
1.488 - * in polar coordinates that corresponds to the point
1.489 - * (<i>x</i>, <i>y</i>) in Cartesian coordinates.
1.490 - */
1.491 - public static native double atan2(double y, double x);
1.492 -
1.493 -
1.494 - /**
1.495 - * Returns the value of the first argument raised to the power of the
1.496 - * second argument. Special cases:
1.497 - *
1.498 - * <ul><li>If the second argument is positive or negative zero, then the
1.499 - * result is 1.0.
1.500 - * <li>If the second argument is 1.0, then the result is the same as the
1.501 - * first argument.
1.502 - * <li>If the second argument is NaN, then the result is NaN.
1.503 - * <li>If the first argument is NaN and the second argument is nonzero,
1.504 - * then the result is NaN.
1.505 - *
1.506 - * <li>If
1.507 - * <ul>
1.508 - * <li>the absolute value of the first argument is greater than 1
1.509 - * and the second argument is positive infinity, or
1.510 - * <li>the absolute value of the first argument is less than 1 and
1.511 - * the second argument is negative infinity,
1.512 - * </ul>
1.513 - * then the result is positive infinity.
1.514 - *
1.515 - * <li>If
1.516 - * <ul>
1.517 - * <li>the absolute value of the first argument is greater than 1 and
1.518 - * the second argument is negative infinity, or
1.519 - * <li>the absolute value of the
1.520 - * first argument is less than 1 and the second argument is positive
1.521 - * infinity,
1.522 - * </ul>
1.523 - * then the result is positive zero.
1.524 - *
1.525 - * <li>If the absolute value of the first argument equals 1 and the
1.526 - * second argument is infinite, then the result is NaN.
1.527 - *
1.528 - * <li>If
1.529 - * <ul>
1.530 - * <li>the first argument is positive zero and the second argument
1.531 - * is greater than zero, or
1.532 - * <li>the first argument is positive infinity and the second
1.533 - * argument is less than zero,
1.534 - * </ul>
1.535 - * then the result is positive zero.
1.536 - *
1.537 - * <li>If
1.538 - * <ul>
1.539 - * <li>the first argument is positive zero and the second argument
1.540 - * is less than zero, or
1.541 - * <li>the first argument is positive infinity and the second
1.542 - * argument is greater than zero,
1.543 - * </ul>
1.544 - * then the result is positive infinity.
1.545 - *
1.546 - * <li>If
1.547 - * <ul>
1.548 - * <li>the first argument is negative zero and the second argument
1.549 - * is greater than zero but not a finite odd integer, or
1.550 - * <li>the first argument is negative infinity and the second
1.551 - * argument is less than zero but not a finite odd integer,
1.552 - * </ul>
1.553 - * then the result is positive zero.
1.554 - *
1.555 - * <li>If
1.556 - * <ul>
1.557 - * <li>the first argument is negative zero and the second argument
1.558 - * is a positive finite odd integer, or
1.559 - * <li>the first argument is negative infinity and the second
1.560 - * argument is a negative finite odd integer,
1.561 - * </ul>
1.562 - * then the result is negative zero.
1.563 - *
1.564 - * <li>If
1.565 - * <ul>
1.566 - * <li>the first argument is negative zero and the second argument
1.567 - * is less than zero but not a finite odd integer, or
1.568 - * <li>the first argument is negative infinity and the second
1.569 - * argument is greater than zero but not a finite odd integer,
1.570 - * </ul>
1.571 - * then the result is positive infinity.
1.572 - *
1.573 - * <li>If
1.574 - * <ul>
1.575 - * <li>the first argument is negative zero and the second argument
1.576 - * is a negative finite odd integer, or
1.577 - * <li>the first argument is negative infinity and the second
1.578 - * argument is a positive finite odd integer,
1.579 - * </ul>
1.580 - * then the result is negative infinity.
1.581 - *
1.582 - * <li>If the first argument is finite and less than zero
1.583 - * <ul>
1.584 - * <li> if the second argument is a finite even integer, the
1.585 - * result is equal to the result of raising the absolute value of
1.586 - * the first argument to the power of the second argument
1.587 - *
1.588 - * <li>if the second argument is a finite odd integer, the result
1.589 - * is equal to the negative of the result of raising the absolute
1.590 - * value of the first argument to the power of the second
1.591 - * argument
1.592 - *
1.593 - * <li>if the second argument is finite and not an integer, then
1.594 - * the result is NaN.
1.595 - * </ul>
1.596 - *
1.597 - * <li>If both arguments are integers, then the result is exactly equal
1.598 - * to the mathematical result of raising the first argument to the power
1.599 - * of the second argument if that result can in fact be represented
1.600 - * exactly as a {@code double} value.</ul>
1.601 - *
1.602 - * <p>(In the foregoing descriptions, a floating-point value is
1.603 - * considered to be an integer if and only if it is finite and a
1.604 - * fixed point of the method {@link #ceil ceil} or,
1.605 - * equivalently, a fixed point of the method {@link #floor
1.606 - * floor}. A value is a fixed point of a one-argument
1.607 - * method if and only if the result of applying the method to the
1.608 - * value is equal to the value.)
1.609 - *
1.610 - * @param a base.
1.611 - * @param b the exponent.
1.612 - * @return the value {@code a}<sup>{@code b}</sup>.
1.613 - */
1.614 - public static native double pow(double a, double b);
1.615 -
1.616 - /**
1.617 - * Returns the closest {@code int} to the argument, with ties
1.618 - * rounding up.
1.619 - *
1.620 - * <p>Special cases:
1.621 - * <ul><li>If the argument is NaN, the result is 0.
1.622 - * <li>If the argument is negative infinity or any value less than or
1.623 - * equal to the value of {@code Integer.MIN_VALUE}, the result is
1.624 - * equal to the value of {@code Integer.MIN_VALUE}.
1.625 - * <li>If the argument is positive infinity or any value greater than or
1.626 - * equal to the value of {@code Integer.MAX_VALUE}, the result is
1.627 - * equal to the value of {@code Integer.MAX_VALUE}.</ul>
1.628 - *
1.629 - * @param a a floating-point value to be rounded to an integer.
1.630 - * @return the value of the argument rounded to the nearest
1.631 - * {@code int} value.
1.632 - * @see java.lang.Integer#MAX_VALUE
1.633 - * @see java.lang.Integer#MIN_VALUE
1.634 - */
1.635 - public static int round(float a) {
1.636 - return Math.round(a);
1.637 - }
1.638 -
1.639 - /**
1.640 - * Returns the closest {@code long} to the argument, with ties
1.641 - * rounding up.
1.642 - *
1.643 - * <p>Special cases:
1.644 - * <ul><li>If the argument is NaN, the result is 0.
1.645 - * <li>If the argument is negative infinity or any value less than or
1.646 - * equal to the value of {@code Long.MIN_VALUE}, the result is
1.647 - * equal to the value of {@code Long.MIN_VALUE}.
1.648 - * <li>If the argument is positive infinity or any value greater than or
1.649 - * equal to the value of {@code Long.MAX_VALUE}, the result is
1.650 - * equal to the value of {@code Long.MAX_VALUE}.</ul>
1.651 - *
1.652 - * @param a a floating-point value to be rounded to a
1.653 - * {@code long}.
1.654 - * @return the value of the argument rounded to the nearest
1.655 - * {@code long} value.
1.656 - * @see java.lang.Long#MAX_VALUE
1.657 - * @see java.lang.Long#MIN_VALUE
1.658 - */
1.659 - public static long round(double a) {
1.660 - return Math.round(a);
1.661 - }
1.662 -
1.663 - /**
1.664 - * Returns a {@code double} value with a positive sign, greater
1.665 - * than or equal to {@code 0.0} and less than {@code 1.0}.
1.666 - * Returned values are chosen pseudorandomly with (approximately)
1.667 - * uniform distribution from that range.
1.668 - *
1.669 - * <p>When this method is first called, it creates a single new
1.670 - * pseudorandom-number generator, exactly as if by the expression
1.671 - *
1.672 - * <blockquote>{@code new java.util.Random()}</blockquote>
1.673 - *
1.674 - * This new pseudorandom-number generator is used thereafter for
1.675 - * all calls to this method and is used nowhere else.
1.676 - *
1.677 - * <p>This method is properly synchronized to allow correct use by
1.678 - * more than one thread. However, if many threads need to generate
1.679 - * pseudorandom numbers at a great rate, it may reduce contention
1.680 - * for each thread to have its own pseudorandom number generator.
1.681 - *
1.682 - * @return a pseudorandom {@code double} greater than or equal
1.683 - * to {@code 0.0} and less than {@code 1.0}.
1.684 - * @see Random#nextDouble()
1.685 - */
1.686 - public static double random() {
1.687 - throw new UnsupportedOperationException();
1.688 - }
1.689 -
1.690 - /**
1.691 - * Returns the absolute value of an {@code int} value..
1.692 - * If the argument is not negative, the argument is returned.
1.693 - * If the argument is negative, the negation of the argument is returned.
1.694 - *
1.695 - * <p>Note that if the argument is equal to the value of
1.696 - * {@link Integer#MIN_VALUE}, the most negative representable
1.697 - * {@code int} value, the result is that same value, which is
1.698 - * negative.
1.699 - *
1.700 - * @param a the argument whose absolute value is to be determined.
1.701 - * @return the absolute value of the argument.
1.702 - */
1.703 - public static int abs(int a) {
1.704 - return (a < 0) ? -a : a;
1.705 - }
1.706 -
1.707 - /**
1.708 - * Returns the absolute value of a {@code long} value.
1.709 - * If the argument is not negative, the argument is returned.
1.710 - * If the argument is negative, the negation of the argument is returned.
1.711 - *
1.712 - * <p>Note that if the argument is equal to the value of
1.713 - * {@link Long#MIN_VALUE}, the most negative representable
1.714 - * {@code long} value, the result is that same value, which
1.715 - * is negative.
1.716 - *
1.717 - * @param a the argument whose absolute value is to be determined.
1.718 - * @return the absolute value of the argument.
1.719 - */
1.720 - public static long abs(long a) {
1.721 - return (a < 0) ? -a : a;
1.722 - }
1.723 -
1.724 - /**
1.725 - * Returns the absolute value of a {@code float} value.
1.726 - * If the argument is not negative, the argument is returned.
1.727 - * If the argument is negative, the negation of the argument is returned.
1.728 - * Special cases:
1.729 - * <ul><li>If the argument is positive zero or negative zero, the
1.730 - * result is positive zero.
1.731 - * <li>If the argument is infinite, the result is positive infinity.
1.732 - * <li>If the argument is NaN, the result is NaN.</ul>
1.733 - * In other words, the result is the same as the value of the expression:
1.734 - * <p>{@code Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))}
1.735 - *
1.736 - * @param a the argument whose absolute value is to be determined
1.737 - * @return the absolute value of the argument.
1.738 - */
1.739 - public static float abs(float a) {
1.740 - return (a <= 0.0F) ? 0.0F - a : a;
1.741 - }
1.742 -
1.743 - /**
1.744 - * Returns the absolute value of a {@code double} value.
1.745 - * If the argument is not negative, the argument is returned.
1.746 - * If the argument is negative, the negation of the argument is returned.
1.747 - * Special cases:
1.748 - * <ul><li>If the argument is positive zero or negative zero, the result
1.749 - * is positive zero.
1.750 - * <li>If the argument is infinite, the result is positive infinity.
1.751 - * <li>If the argument is NaN, the result is NaN.</ul>
1.752 - * In other words, the result is the same as the value of the expression:
1.753 - * <p>{@code Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)}
1.754 - *
1.755 - * @param a the argument whose absolute value is to be determined
1.756 - * @return the absolute value of the argument.
1.757 - */
1.758 - public static double abs(double a) {
1.759 - return (a <= 0.0D) ? 0.0D - a : a;
1.760 - }
1.761 -
1.762 - /**
1.763 - * Returns the greater of two {@code int} values. That is, the
1.764 - * result is the argument closer to the value of
1.765 - * {@link Integer#MAX_VALUE}. If the arguments have the same value,
1.766 - * the result is that same value.
1.767 - *
1.768 - * @param a an argument.
1.769 - * @param b another argument.
1.770 - * @return the larger of {@code a} and {@code b}.
1.771 - */
1.772 - public static int max(int a, int b) {
1.773 - return (a >= b) ? a : b;
1.774 - }
1.775 -
1.776 - /**
1.777 - * Returns the greater of two {@code long} values. That is, the
1.778 - * result is the argument closer to the value of
1.779 - * {@link Long#MAX_VALUE}. If the arguments have the same value,
1.780 - * the result is that same value.
1.781 - *
1.782 - * @param a an argument.
1.783 - * @param b another argument.
1.784 - * @return the larger of {@code a} and {@code b}.
1.785 - */
1.786 - public static long max(long a, long b) {
1.787 - return (a >= b) ? a : b;
1.788 - }
1.789 -
1.790 - // Use raw bit-wise conversions on guaranteed non-NaN arguments.
1.791 - private static long negativeZeroFloatBits = Float.floatToRawIntBits(-0.0f);
1.792 - private static long negativeZeroDoubleBits = Double.doubleToRawLongBits(-0.0d);
1.793 -
1.794 - /**
1.795 - * Returns the greater of two {@code float} values. That is,
1.796 - * the result is the argument closer to positive infinity. If the
1.797 - * arguments have the same value, the result is that same
1.798 - * value. If either value is NaN, then the result is NaN. Unlike
1.799 - * the numerical comparison operators, this method considers
1.800 - * negative zero to be strictly smaller than positive zero. If one
1.801 - * argument is positive zero and the other negative zero, the
1.802 - * result is positive zero.
1.803 - *
1.804 - * @param a an argument.
1.805 - * @param b another argument.
1.806 - * @return the larger of {@code a} and {@code b}.
1.807 - */
1.808 - public static float max(float a, float b) {
1.809 - if (a != a)
1.810 - return a; // a is NaN
1.811 - if ((a == 0.0f) &&
1.812 - (b == 0.0f) &&
1.813 - (Float.floatToRawIntBits(a) == negativeZeroFloatBits)) {
1.814 - // Raw conversion ok since NaN can't map to -0.0.
1.815 - return b;
1.816 - }
1.817 - return (a >= b) ? a : b;
1.818 - }
1.819 -
1.820 - /**
1.821 - * Returns the greater of two {@code double} values. That
1.822 - * is, the result is the argument closer to positive infinity. If
1.823 - * the arguments have the same value, the result is that same
1.824 - * value. If either value is NaN, then the result is NaN. Unlike
1.825 - * the numerical comparison operators, this method considers
1.826 - * negative zero to be strictly smaller than positive zero. If one
1.827 - * argument is positive zero and the other negative zero, the
1.828 - * result is positive zero.
1.829 - *
1.830 - * @param a an argument.
1.831 - * @param b another argument.
1.832 - * @return the larger of {@code a} and {@code b}.
1.833 - */
1.834 - public static double max(double a, double b) {
1.835 - if (a != a)
1.836 - return a; // a is NaN
1.837 - if ((a == 0.0d) &&
1.838 - (b == 0.0d) &&
1.839 - (Double.doubleToRawLongBits(a) == negativeZeroDoubleBits)) {
1.840 - // Raw conversion ok since NaN can't map to -0.0.
1.841 - return b;
1.842 - }
1.843 - return (a >= b) ? a : b;
1.844 - }
1.845 -
1.846 - /**
1.847 - * Returns the smaller of two {@code int} values. That is,
1.848 - * the result the argument closer to the value of
1.849 - * {@link Integer#MIN_VALUE}. If the arguments have the same
1.850 - * value, the result is that same value.
1.851 - *
1.852 - * @param a an argument.
1.853 - * @param b another argument.
1.854 - * @return the smaller of {@code a} and {@code b}.
1.855 - */
1.856 - public static int min(int a, int b) {
1.857 - return (a <= b) ? a : b;
1.858 - }
1.859 -
1.860 - /**
1.861 - * Returns the smaller of two {@code long} values. That is,
1.862 - * the result is the argument closer to the value of
1.863 - * {@link Long#MIN_VALUE}. If the arguments have the same
1.864 - * value, the result is that same value.
1.865 - *
1.866 - * @param a an argument.
1.867 - * @param b another argument.
1.868 - * @return the smaller of {@code a} and {@code b}.
1.869 - */
1.870 - public static long min(long a, long b) {
1.871 - return (a <= b) ? a : b;
1.872 - }
1.873 -
1.874 - /**
1.875 - * Returns the smaller of two {@code float} values. That is,
1.876 - * the result is the value closer to negative infinity. If the
1.877 - * arguments have the same value, the result is that same
1.878 - * value. If either value is NaN, then the result is NaN. Unlike
1.879 - * the numerical comparison operators, this method considers
1.880 - * negative zero to be strictly smaller than positive zero. If
1.881 - * one argument is positive zero and the other is negative zero,
1.882 - * the result is negative zero.
1.883 - *
1.884 - * @param a an argument.
1.885 - * @param b another argument.
1.886 - * @return the smaller of {@code a} and {@code b.}
1.887 - */
1.888 - public static float min(float a, float b) {
1.889 - if (a != a)
1.890 - return a; // a is NaN
1.891 - if ((a == 0.0f) &&
1.892 - (b == 0.0f) &&
1.893 - (Float.floatToRawIntBits(b) == negativeZeroFloatBits)) {
1.894 - // Raw conversion ok since NaN can't map to -0.0.
1.895 - return b;
1.896 - }
1.897 - return (a <= b) ? a : b;
1.898 - }
1.899 -
1.900 - /**
1.901 - * Returns the smaller of two {@code double} values. That
1.902 - * is, the result is the value closer to negative infinity. If the
1.903 - * arguments have the same value, the result is that same
1.904 - * value. If either value is NaN, then the result is NaN. Unlike
1.905 - * the numerical comparison operators, this method considers
1.906 - * negative zero to be strictly smaller than positive zero. If one
1.907 - * argument is positive zero and the other is negative zero, the
1.908 - * result is negative zero.
1.909 - *
1.910 - * @param a an argument.
1.911 - * @param b another argument.
1.912 - * @return the smaller of {@code a} and {@code b}.
1.913 - */
1.914 - public static double min(double a, double b) {
1.915 - if (a != a)
1.916 - return a; // a is NaN
1.917 - if ((a == 0.0d) &&
1.918 - (b == 0.0d) &&
1.919 - (Double.doubleToRawLongBits(b) == negativeZeroDoubleBits)) {
1.920 - // Raw conversion ok since NaN can't map to -0.0.
1.921 - return b;
1.922 - }
1.923 - return (a <= b) ? a : b;
1.924 - }
1.925 -
1.926 - /**
1.927 - * Returns the size of an ulp of the argument. An ulp of a
1.928 - * {@code double} value is the positive distance between this
1.929 - * floating-point value and the {@code double} value next
1.930 - * larger in magnitude. Note that for non-NaN <i>x</i>,
1.931 - * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
1.932 - *
1.933 - * <p>Special Cases:
1.934 - * <ul>
1.935 - * <li> If the argument is NaN, then the result is NaN.
1.936 - * <li> If the argument is positive or negative infinity, then the
1.937 - * result is positive infinity.
1.938 - * <li> If the argument is positive or negative zero, then the result is
1.939 - * {@code Double.MIN_VALUE}.
1.940 - * <li> If the argument is ±{@code Double.MAX_VALUE}, then
1.941 - * the result is equal to 2<sup>971</sup>.
1.942 - * </ul>
1.943 - *
1.944 - * @param d the floating-point value whose ulp is to be returned
1.945 - * @return the size of an ulp of the argument
1.946 - * @author Joseph D. Darcy
1.947 - * @since 1.5
1.948 - */
1.949 - public static double ulp(double d) {
1.950 - throw new UnsupportedOperationException();
1.951 - }
1.952 -
1.953 - /**
1.954 - * Returns the size of an ulp of the argument. An ulp of a
1.955 - * {@code float} value is the positive distance between this
1.956 - * floating-point value and the {@code float} value next
1.957 - * larger in magnitude. Note that for non-NaN <i>x</i>,
1.958 - * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
1.959 - *
1.960 - * <p>Special Cases:
1.961 - * <ul>
1.962 - * <li> If the argument is NaN, then the result is NaN.
1.963 - * <li> If the argument is positive or negative infinity, then the
1.964 - * result is positive infinity.
1.965 - * <li> If the argument is positive or negative zero, then the result is
1.966 - * {@code Float.MIN_VALUE}.
1.967 - * <li> If the argument is ±{@code Float.MAX_VALUE}, then
1.968 - * the result is equal to 2<sup>104</sup>.
1.969 - * </ul>
1.970 - *
1.971 - * @param f the floating-point value whose ulp is to be returned
1.972 - * @return the size of an ulp of the argument
1.973 - * @author Joseph D. Darcy
1.974 - * @since 1.5
1.975 - */
1.976 - public static float ulp(float f) {
1.977 - throw new UnsupportedOperationException();
1.978 - }
1.979 -
1.980 - /**
1.981 - * Returns the signum function of the argument; zero if the argument
1.982 - * is zero, 1.0 if the argument is greater than zero, -1.0 if the
1.983 - * argument is less than zero.
1.984 - *
1.985 - * <p>Special Cases:
1.986 - * <ul>
1.987 - * <li> If the argument is NaN, then the result is NaN.
1.988 - * <li> If the argument is positive zero or negative zero, then the
1.989 - * result is the same as the argument.
1.990 - * </ul>
1.991 - *
1.992 - * @param d the floating-point value whose signum is to be returned
1.993 - * @return the signum function of the argument
1.994 - * @author Joseph D. Darcy
1.995 - * @since 1.5
1.996 - */
1.997 - public static double signum(double d) {
1.998 - throw new UnsupportedOperationException();
1.999 - }
1.1000 -
1.1001 - /**
1.1002 - * Returns the signum function of the argument; zero if the argument
1.1003 - * is zero, 1.0f if the argument is greater than zero, -1.0f if the
1.1004 - * argument is less than zero.
1.1005 - *
1.1006 - * <p>Special Cases:
1.1007 - * <ul>
1.1008 - * <li> If the argument is NaN, then the result is NaN.
1.1009 - * <li> If the argument is positive zero or negative zero, then the
1.1010 - * result is the same as the argument.
1.1011 - * </ul>
1.1012 - *
1.1013 - * @param f the floating-point value whose signum is to be returned
1.1014 - * @return the signum function of the argument
1.1015 - * @author Joseph D. Darcy
1.1016 - * @since 1.5
1.1017 - */
1.1018 - public static float signum(float f) {
1.1019 - throw new UnsupportedOperationException();
1.1020 - }
1.1021 -
1.1022 - /**
1.1023 - * Returns the hyperbolic sine of a {@code double} value.
1.1024 - * The hyperbolic sine of <i>x</i> is defined to be
1.1025 - * (<i>e<sup>x</sup> - e<sup>-x</sup></i>)/2
1.1026 - * where <i>e</i> is {@linkplain Math#E Euler's number}.
1.1027 - *
1.1028 - * <p>Special cases:
1.1029 - * <ul>
1.1030 - *
1.1031 - * <li>If the argument is NaN, then the result is NaN.
1.1032 - *
1.1033 - * <li>If the argument is infinite, then the result is an infinity
1.1034 - * with the same sign as the argument.
1.1035 - *
1.1036 - * <li>If the argument is zero, then the result is a zero with the
1.1037 - * same sign as the argument.
1.1038 - *
1.1039 - * </ul>
1.1040 - *
1.1041 - * @param x The number whose hyperbolic sine is to be returned.
1.1042 - * @return The hyperbolic sine of {@code x}.
1.1043 - * @since 1.5
1.1044 - */
1.1045 - public static native double sinh(double x);
1.1046 -
1.1047 - /**
1.1048 - * Returns the hyperbolic cosine of a {@code double} value.
1.1049 - * The hyperbolic cosine of <i>x</i> is defined to be
1.1050 - * (<i>e<sup>x</sup> + e<sup>-x</sup></i>)/2
1.1051 - * where <i>e</i> is {@linkplain Math#E Euler's number}.
1.1052 - *
1.1053 - * <p>Special cases:
1.1054 - * <ul>
1.1055 - *
1.1056 - * <li>If the argument is NaN, then the result is NaN.
1.1057 - *
1.1058 - * <li>If the argument is infinite, then the result is positive
1.1059 - * infinity.
1.1060 - *
1.1061 - * <li>If the argument is zero, then the result is {@code 1.0}.
1.1062 - *
1.1063 - * </ul>
1.1064 - *
1.1065 - * @param x The number whose hyperbolic cosine is to be returned.
1.1066 - * @return The hyperbolic cosine of {@code x}.
1.1067 - * @since 1.5
1.1068 - */
1.1069 - public static native double cosh(double x);
1.1070 -
1.1071 - /**
1.1072 - * Returns the hyperbolic tangent of a {@code double} value.
1.1073 - * The hyperbolic tangent of <i>x</i> is defined to be
1.1074 - * (<i>e<sup>x</sup> - e<sup>-x</sup></i>)/(<i>e<sup>x</sup> + e<sup>-x</sup></i>),
1.1075 - * in other words, {@linkplain Math#sinh
1.1076 - * sinh(<i>x</i>)}/{@linkplain Math#cosh cosh(<i>x</i>)}. Note
1.1077 - * that the absolute value of the exact tanh is always less than
1.1078 - * 1.
1.1079 - *
1.1080 - * <p>Special cases:
1.1081 - * <ul>
1.1082 - *
1.1083 - * <li>If the argument is NaN, then the result is NaN.
1.1084 - *
1.1085 - * <li>If the argument is zero, then the result is a zero with the
1.1086 - * same sign as the argument.
1.1087 - *
1.1088 - * <li>If the argument is positive infinity, then the result is
1.1089 - * {@code +1.0}.
1.1090 - *
1.1091 - * <li>If the argument is negative infinity, then the result is
1.1092 - * {@code -1.0}.
1.1093 - *
1.1094 - * </ul>
1.1095 - *
1.1096 - * @param x The number whose hyperbolic tangent is to be returned.
1.1097 - * @return The hyperbolic tangent of {@code x}.
1.1098 - * @since 1.5
1.1099 - */
1.1100 - public static native double tanh(double x);
1.1101 -
1.1102 - /**
1.1103 - * Returns sqrt(<i>x</i><sup>2</sup> +<i>y</i><sup>2</sup>)
1.1104 - * without intermediate overflow or underflow.
1.1105 - *
1.1106 - * <p>Special cases:
1.1107 - * <ul>
1.1108 - *
1.1109 - * <li> If either argument is infinite, then the result
1.1110 - * is positive infinity.
1.1111 - *
1.1112 - * <li> If either argument is NaN and neither argument is infinite,
1.1113 - * then the result is NaN.
1.1114 - *
1.1115 - * </ul>
1.1116 - *
1.1117 - * @param x a value
1.1118 - * @param y a value
1.1119 - * @return sqrt(<i>x</i><sup>2</sup> +<i>y</i><sup>2</sup>)
1.1120 - * without intermediate overflow or underflow
1.1121 - * @since 1.5
1.1122 - */
1.1123 - public static native double hypot(double x, double y);
1.1124 -
1.1125 - /**
1.1126 - * Returns <i>e</i><sup>x</sup> -1. Note that for values of
1.1127 - * <i>x</i> near 0, the exact sum of
1.1128 - * {@code expm1(x)} + 1 is much closer to the true
1.1129 - * result of <i>e</i><sup>x</sup> than {@code exp(x)}.
1.1130 - *
1.1131 - * <p>Special cases:
1.1132 - * <ul>
1.1133 - * <li>If the argument is NaN, the result is NaN.
1.1134 - *
1.1135 - * <li>If the argument is positive infinity, then the result is
1.1136 - * positive infinity.
1.1137 - *
1.1138 - * <li>If the argument is negative infinity, then the result is
1.1139 - * -1.0.
1.1140 - *
1.1141 - * <li>If the argument is zero, then the result is a zero with the
1.1142 - * same sign as the argument.
1.1143 - *
1.1144 - * </ul>
1.1145 - *
1.1146 - * @param x the exponent to raise <i>e</i> to in the computation of
1.1147 - * <i>e</i><sup>{@code x}</sup> -1.
1.1148 - * @return the value <i>e</i><sup>{@code x}</sup> - 1.
1.1149 - * @since 1.5
1.1150 - */
1.1151 - public static native double expm1(double x);
1.1152 -
1.1153 - /**
1.1154 - * Returns the natural logarithm of the sum of the argument and 1.
1.1155 - * Note that for small values {@code x}, the result of
1.1156 - * {@code log1p(x)} is much closer to the true result of ln(1
1.1157 - * + {@code x}) than the floating-point evaluation of
1.1158 - * {@code log(1.0+x)}.
1.1159 - *
1.1160 - * <p>Special cases:
1.1161 - * <ul>
1.1162 - *
1.1163 - * <li>If the argument is NaN or less than -1, then the result is
1.1164 - * NaN.
1.1165 - *
1.1166 - * <li>If the argument is positive infinity, then the result is
1.1167 - * positive infinity.
1.1168 - *
1.1169 - * <li>If the argument is negative one, then the result is
1.1170 - * negative infinity.
1.1171 - *
1.1172 - * <li>If the argument is zero, then the result is a zero with the
1.1173 - * same sign as the argument.
1.1174 - *
1.1175 - * </ul>
1.1176 - *
1.1177 - * @param x a value
1.1178 - * @return the value ln({@code x} + 1), the natural
1.1179 - * log of {@code x} + 1
1.1180 - * @since 1.5
1.1181 - */
1.1182 - public static native double log1p(double x);
1.1183 -
1.1184 - /**
1.1185 - * Returns the first floating-point argument with the sign of the
1.1186 - * second floating-point argument. For this method, a NaN
1.1187 - * {@code sign} argument is always treated as if it were
1.1188 - * positive.
1.1189 - *
1.1190 - * @param magnitude the parameter providing the magnitude of the result
1.1191 - * @param sign the parameter providing the sign of the result
1.1192 - * @return a value with the magnitude of {@code magnitude}
1.1193 - * and the sign of {@code sign}.
1.1194 - * @since 1.6
1.1195 - */
1.1196 - public static double copySign(double magnitude, double sign) {
1.1197 - throw new UnsupportedOperationException();
1.1198 - }
1.1199 -
1.1200 - /**
1.1201 - * Returns the first floating-point argument with the sign of the
1.1202 - * second floating-point argument. For this method, a NaN
1.1203 - * {@code sign} argument is always treated as if it were
1.1204 - * positive.
1.1205 - *
1.1206 - * @param magnitude the parameter providing the magnitude of the result
1.1207 - * @param sign the parameter providing the sign of the result
1.1208 - * @return a value with the magnitude of {@code magnitude}
1.1209 - * and the sign of {@code sign}.
1.1210 - * @since 1.6
1.1211 - */
1.1212 - public static float copySign(float magnitude, float sign) {
1.1213 - throw new UnsupportedOperationException();
1.1214 - }
1.1215 - /**
1.1216 - * Returns the unbiased exponent used in the representation of a
1.1217 - * {@code float}. Special cases:
1.1218 - *
1.1219 - * <ul>
1.1220 - * <li>If the argument is NaN or infinite, then the result is
1.1221 - * {@link Float#MAX_EXPONENT} + 1.
1.1222 - * <li>If the argument is zero or subnormal, then the result is
1.1223 - * {@link Float#MIN_EXPONENT} -1.
1.1224 - * </ul>
1.1225 - * @param f a {@code float} value
1.1226 - * @since 1.6
1.1227 - */
1.1228 - public static int getExponent(float f) {
1.1229 - throw new UnsupportedOperationException();
1.1230 - }
1.1231 -
1.1232 - /**
1.1233 - * Returns the unbiased exponent used in the representation of a
1.1234 - * {@code double}. Special cases:
1.1235 - *
1.1236 - * <ul>
1.1237 - * <li>If the argument is NaN or infinite, then the result is
1.1238 - * {@link Double#MAX_EXPONENT} + 1.
1.1239 - * <li>If the argument is zero or subnormal, then the result is
1.1240 - * {@link Double#MIN_EXPONENT} -1.
1.1241 - * </ul>
1.1242 - * @param d a {@code double} value
1.1243 - * @since 1.6
1.1244 - */
1.1245 - public static int getExponent(double d) {
1.1246 - throw new UnsupportedOperationException();
1.1247 - }
1.1248 -
1.1249 - /**
1.1250 - * Returns the floating-point number adjacent to the first
1.1251 - * argument in the direction of the second argument. If both
1.1252 - * arguments compare as equal the second argument is returned.
1.1253 - *
1.1254 - * <p>Special cases:
1.1255 - * <ul>
1.1256 - * <li> If either argument is a NaN, then NaN is returned.
1.1257 - *
1.1258 - * <li> If both arguments are signed zeros, {@code direction}
1.1259 - * is returned unchanged (as implied by the requirement of
1.1260 - * returning the second argument if the arguments compare as
1.1261 - * equal).
1.1262 - *
1.1263 - * <li> If {@code start} is
1.1264 - * ±{@link Double#MIN_VALUE} and {@code direction}
1.1265 - * has a value such that the result should have a smaller
1.1266 - * magnitude, then a zero with the same sign as {@code start}
1.1267 - * is returned.
1.1268 - *
1.1269 - * <li> If {@code start} is infinite and
1.1270 - * {@code direction} has a value such that the result should
1.1271 - * have a smaller magnitude, {@link Double#MAX_VALUE} with the
1.1272 - * same sign as {@code start} is returned.
1.1273 - *
1.1274 - * <li> If {@code start} is equal to ±
1.1275 - * {@link Double#MAX_VALUE} and {@code direction} has a
1.1276 - * value such that the result should have a larger magnitude, an
1.1277 - * infinity with same sign as {@code start} is returned.
1.1278 - * </ul>
1.1279 - *
1.1280 - * @param start starting floating-point value
1.1281 - * @param direction value indicating which of
1.1282 - * {@code start}'s neighbors or {@code start} should
1.1283 - * be returned
1.1284 - * @return The floating-point number adjacent to {@code start} in the
1.1285 - * direction of {@code direction}.
1.1286 - * @since 1.6
1.1287 - */
1.1288 - public static double nextAfter(double start, double direction) {
1.1289 - throw new UnsupportedOperationException();
1.1290 - }
1.1291 -
1.1292 - /**
1.1293 - * Returns the floating-point number adjacent to the first
1.1294 - * argument in the direction of the second argument. If both
1.1295 - * arguments compare as equal a value equivalent to the second argument
1.1296 - * is returned.
1.1297 - *
1.1298 - * <p>Special cases:
1.1299 - * <ul>
1.1300 - * <li> If either argument is a NaN, then NaN is returned.
1.1301 - *
1.1302 - * <li> If both arguments are signed zeros, a value equivalent
1.1303 - * to {@code direction} is returned.
1.1304 - *
1.1305 - * <li> If {@code start} is
1.1306 - * ±{@link Float#MIN_VALUE} and {@code direction}
1.1307 - * has a value such that the result should have a smaller
1.1308 - * magnitude, then a zero with the same sign as {@code start}
1.1309 - * is returned.
1.1310 - *
1.1311 - * <li> If {@code start} is infinite and
1.1312 - * {@code direction} has a value such that the result should
1.1313 - * have a smaller magnitude, {@link Float#MAX_VALUE} with the
1.1314 - * same sign as {@code start} is returned.
1.1315 - *
1.1316 - * <li> If {@code start} is equal to ±
1.1317 - * {@link Float#MAX_VALUE} and {@code direction} has a
1.1318 - * value such that the result should have a larger magnitude, an
1.1319 - * infinity with same sign as {@code start} is returned.
1.1320 - * </ul>
1.1321 - *
1.1322 - * @param start starting floating-point value
1.1323 - * @param direction value indicating which of
1.1324 - * {@code start}'s neighbors or {@code start} should
1.1325 - * be returned
1.1326 - * @return The floating-point number adjacent to {@code start} in the
1.1327 - * direction of {@code direction}.
1.1328 - * @since 1.6
1.1329 - */
1.1330 - public static float nextAfter(float start, double direction) {
1.1331 - throw new UnsupportedOperationException();
1.1332 - }
1.1333 -
1.1334 - /**
1.1335 - * Returns the floating-point value adjacent to {@code d} in
1.1336 - * the direction of positive infinity. This method is
1.1337 - * semantically equivalent to {@code nextAfter(d,
1.1338 - * Double.POSITIVE_INFINITY)}; however, a {@code nextUp}
1.1339 - * implementation may run faster than its equivalent
1.1340 - * {@code nextAfter} call.
1.1341 - *
1.1342 - * <p>Special Cases:
1.1343 - * <ul>
1.1344 - * <li> If the argument is NaN, the result is NaN.
1.1345 - *
1.1346 - * <li> If the argument is positive infinity, the result is
1.1347 - * positive infinity.
1.1348 - *
1.1349 - * <li> If the argument is zero, the result is
1.1350 - * {@link Double#MIN_VALUE}
1.1351 - *
1.1352 - * </ul>
1.1353 - *
1.1354 - * @param d starting floating-point value
1.1355 - * @return The adjacent floating-point value closer to positive
1.1356 - * infinity.
1.1357 - * @since 1.6
1.1358 - */
1.1359 - public static double nextUp(double d) {
1.1360 - throw new UnsupportedOperationException();
1.1361 - }
1.1362 -
1.1363 - /**
1.1364 - * Returns the floating-point value adjacent to {@code f} in
1.1365 - * the direction of positive infinity. This method is
1.1366 - * semantically equivalent to {@code nextAfter(f,
1.1367 - * Float.POSITIVE_INFINITY)}; however, a {@code nextUp}
1.1368 - * implementation may run faster than its equivalent
1.1369 - * {@code nextAfter} call.
1.1370 - *
1.1371 - * <p>Special Cases:
1.1372 - * <ul>
1.1373 - * <li> If the argument is NaN, the result is NaN.
1.1374 - *
1.1375 - * <li> If the argument is positive infinity, the result is
1.1376 - * positive infinity.
1.1377 - *
1.1378 - * <li> If the argument is zero, the result is
1.1379 - * {@link Float#MIN_VALUE}
1.1380 - *
1.1381 - * </ul>
1.1382 - *
1.1383 - * @param f starting floating-point value
1.1384 - * @return The adjacent floating-point value closer to positive
1.1385 - * infinity.
1.1386 - * @since 1.6
1.1387 - */
1.1388 - public static float nextUp(float f) {
1.1389 - throw new UnsupportedOperationException();
1.1390 - }
1.1391 -
1.1392 -
1.1393 - /**
1.1394 - * Return {@code d} ×
1.1395 - * 2<sup>{@code scaleFactor}</sup> rounded as if performed
1.1396 - * by a single correctly rounded floating-point multiply to a
1.1397 - * member of the double value set. See the Java
1.1398 - * Language Specification for a discussion of floating-point
1.1399 - * value sets. If the exponent of the result is between {@link
1.1400 - * Double#MIN_EXPONENT} and {@link Double#MAX_EXPONENT}, the
1.1401 - * answer is calculated exactly. If the exponent of the result
1.1402 - * would be larger than {@code Double.MAX_EXPONENT}, an
1.1403 - * infinity is returned. Note that if the result is subnormal,
1.1404 - * precision may be lost; that is, when {@code scalb(x, n)}
1.1405 - * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
1.1406 - * <i>x</i>. When the result is non-NaN, the result has the same
1.1407 - * sign as {@code d}.
1.1408 - *
1.1409 - * <p>Special cases:
1.1410 - * <ul>
1.1411 - * <li> If the first argument is NaN, NaN is returned.
1.1412 - * <li> If the first argument is infinite, then an infinity of the
1.1413 - * same sign is returned.
1.1414 - * <li> If the first argument is zero, then a zero of the same
1.1415 - * sign is returned.
1.1416 - * </ul>
1.1417 - *
1.1418 - * @param d number to be scaled by a power of two.
1.1419 - * @param scaleFactor power of 2 used to scale {@code d}
1.1420 - * @return {@code d} × 2<sup>{@code scaleFactor}</sup>
1.1421 - * @since 1.6
1.1422 - */
1.1423 - public static double scalb(double d, int scaleFactor) {
1.1424 - throw new UnsupportedOperationException();
1.1425 - }
1.1426 -
1.1427 - /**
1.1428 - * Return {@code f} ×
1.1429 - * 2<sup>{@code scaleFactor}</sup> rounded as if performed
1.1430 - * by a single correctly rounded floating-point multiply to a
1.1431 - * member of the float value set. See the Java
1.1432 - * Language Specification for a discussion of floating-point
1.1433 - * value sets. If the exponent of the result is between {@link
1.1434 - * Float#MIN_EXPONENT} and {@link Float#MAX_EXPONENT}, the
1.1435 - * answer is calculated exactly. If the exponent of the result
1.1436 - * would be larger than {@code Float.MAX_EXPONENT}, an
1.1437 - * infinity is returned. Note that if the result is subnormal,
1.1438 - * precision may be lost; that is, when {@code scalb(x, n)}
1.1439 - * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
1.1440 - * <i>x</i>. When the result is non-NaN, the result has the same
1.1441 - * sign as {@code f}.
1.1442 - *
1.1443 - * <p>Special cases:
1.1444 - * <ul>
1.1445 - * <li> If the first argument is NaN, NaN is returned.
1.1446 - * <li> If the first argument is infinite, then an infinity of the
1.1447 - * same sign is returned.
1.1448 - * <li> If the first argument is zero, then a zero of the same
1.1449 - * sign is returned.
1.1450 - * </ul>
1.1451 - *
1.1452 - * @param f number to be scaled by a power of two.
1.1453 - * @param scaleFactor power of 2 used to scale {@code f}
1.1454 - * @return {@code f} × 2<sup>{@code scaleFactor}</sup>
1.1455 - * @since 1.6
1.1456 - */
1.1457 - public static float scalb(float f, int scaleFactor) {
1.1458 - throw new UnsupportedOperationException();
1.1459 - }
1.1460 -}