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