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