jdk/test/java/lang/Math/RoundTests.java
author jrose
Sat, 05 Oct 2013 05:30:38 -0700
changeset 20528 0b1e2130d3f7
parent 19851 7b6ff45c39ce
permissions -rw-r--r--
8001105: findVirtual of Object[].clone produces internal error Summary: Replicate JVM logic for access control that makes Object.clone appear public when applied to an array type. Reviewed-by: twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9269
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
     1
/*
19851
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
     2
 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
9269
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
     4
 *
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
     8
 *
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    13
 * accompanied this code).
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    14
 *
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    18
 *
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    21
 * questions.
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    22
 */
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    23
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    24
/*
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    25
 * @test
19851
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
    26
 * @bug 6430675 8010430
9269
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    27
 * @summary Check for correct implementation of {Math, StrictMath}.round
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    28
 */
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    29
public class RoundTests {
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    30
    public static void main(String... args) {
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    31
        int failures = 0;
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    32
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    33
        failures += testNearFloatHalfCases();
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    34
        failures += testNearDoubleHalfCases();
19851
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
    35
        failures += testUnityULPCases();
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
    36
        failures += testSpecialCases();
9269
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    37
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    38
        if (failures > 0) {
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    39
            System.err.println("Testing {Math, StrictMath}.round incurred "
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    40
                               + failures + " failures.");
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    41
            throw new RuntimeException();
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    42
        }
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    43
    }
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    44
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    45
    private static int testNearDoubleHalfCases() {
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    46
        int failures = 0;
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    47
        double [][] testCases = {
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    48
            {+0x1.fffffffffffffp-2,  0.0},
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    49
            {+0x1.0p-1,              1.0}, // +0.5
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    50
            {+0x1.0000000000001p-1,  1.0},
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    51
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    52
            {-0x1.fffffffffffffp-2,  0.0},
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    53
            {-0x1.0p-1,              0.0}, // -0.5
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    54
            {-0x1.0000000000001p-1, -1.0},
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    55
        };
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    56
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    57
        for(double[] testCase : testCases) {
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    58
            failures += testNearHalfCases(testCase[0], (long)testCase[1]);
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    59
        }
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    60
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    61
        return failures;
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    62
    }
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    63
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    64
    private static int testNearHalfCases(double input, double expected) {
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    65
        int failures = 0;
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    66
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    67
        failures += Tests.test("Math.round",        input, Math.round(input),       expected);
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    68
        failures += Tests.test("StrictMath.round",  input, StrictMath.round(input), expected);
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    69
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    70
        return failures;
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    71
    }
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    72
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    73
    private static int testNearFloatHalfCases() {
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    74
        int failures = 0;
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    75
        float [][] testCases = {
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    76
            {+0x1.fffffep-2f,  0.0f},
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    77
            {+0x1.0p-1f,       1.0f}, // +0.5
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    78
            {+0x1.000002p-1f,  1.0f},
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    79
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    80
            {-0x1.fffffep-2f,  0.0f},
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    81
            {-0x1.0p-1f,       0.0f}, // -0.5
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    82
            {-0x1.000002p-1f, -1.0f},
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    83
        };
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    84
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    85
        for(float[] testCase : testCases) {
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    86
            failures += testNearHalfCases(testCase[0], (int)testCase[1]);
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    87
        }
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    88
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    89
        return failures;
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    90
    }
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    91
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    92
    private static int testNearHalfCases(float input, float expected) {
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    93
        int failures = 0;
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    94
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    95
        failures += Tests.test("Math.round",        input, Math.round(input),       expected);
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    96
        failures += Tests.test("StrictMath.round",  input, StrictMath.round(input), expected);
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    97
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    98
        return failures;
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
    99
    }
19851
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   100
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   101
    private static int testUnityULPCases() {
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   102
        int failures = 0;
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   103
        for (float sign : new float[]{-1, 1}) {
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   104
            for (float v1 : new float[]{1 << 23, 1 << 24}) {
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   105
                for (int k = -5; k <= 5; k++) {
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   106
                    float value = (v1 + k) * sign;
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   107
                    float actual = Math.round(value);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   108
                    failures += Tests.test("Math.round", value, actual, value);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   109
                }
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   110
            }
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   111
        }
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   112
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   113
        if (failures != 0) {
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   114
            System.out.println();
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   115
        }
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   116
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   117
        for (double sign : new double[]{-1, 1}) {
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   118
            for (double v1 : new double[]{1L << 52, 1L << 53}) {
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   119
                for (int k = -5; k <= 5; k++) {
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   120
                    double value = (v1 + k) * sign;
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   121
                    double actual = Math.round(value);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   122
                    failures += Tests.test("Math.round", value, actual, value);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   123
                }
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   124
            }
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   125
        }
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   126
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   127
        return failures;
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   128
    }
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   129
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   130
    private static int testSpecialCases() {
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   131
        int failures = 0;
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   132
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   133
        failures += Tests.test("Math.round", Float.NaN, Math.round(Float.NaN), 0.0F);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   134
        failures += Tests.test("Math.round", Float.POSITIVE_INFINITY,
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   135
                Math.round(Float.POSITIVE_INFINITY), Integer.MAX_VALUE);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   136
        failures += Tests.test("Math.round", Float.NEGATIVE_INFINITY,
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   137
                Math.round(Float.NEGATIVE_INFINITY), Integer.MIN_VALUE);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   138
        failures += Tests.test("Math.round", -(float)Integer.MIN_VALUE,
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   139
                Math.round(-(float)Integer.MIN_VALUE), Integer.MAX_VALUE);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   140
        failures += Tests.test("Math.round", (float) Integer.MIN_VALUE,
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   141
                Math.round((float) Integer.MIN_VALUE), Integer.MIN_VALUE);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   142
        failures += Tests.test("Math.round", 0F, Math.round(0F), 0.0F);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   143
        failures += Tests.test("Math.round", Float.MIN_VALUE,
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   144
                Math.round(Float.MIN_VALUE), 0.0F);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   145
        failures += Tests.test("Math.round", -Float.MIN_VALUE,
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   146
                Math.round(-Float.MIN_VALUE), 0.0F);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   147
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   148
        failures += Tests.test("Math.round", Double.NaN, Math.round(Double.NaN), 0.0);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   149
        failures += Tests.test("Math.round", Double.POSITIVE_INFINITY,
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   150
                Math.round(Double.POSITIVE_INFINITY), Long.MAX_VALUE);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   151
        failures += Tests.test("Math.round", Double.NEGATIVE_INFINITY,
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   152
                Math.round(Double.NEGATIVE_INFINITY), Long.MIN_VALUE);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   153
        failures += Tests.test("Math.round", -(double)Long.MIN_VALUE,
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   154
                Math.round(-(double)Long.MIN_VALUE), Long.MAX_VALUE);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   155
        failures += Tests.test("Math.round", (double) Long.MIN_VALUE,
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   156
                Math.round((double) Long.MIN_VALUE), Long.MIN_VALUE);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   157
        failures += Tests.test("Math.round", 0, Math.round(0), 0.0);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   158
        failures += Tests.test("Math.round", Double.MIN_VALUE,
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   159
                Math.round(Double.MIN_VALUE), 0.0);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   160
        failures += Tests.test("Math.round", -Double.MIN_VALUE,
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   161
                Math.round(-Double.MIN_VALUE), 0.0);
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   162
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   163
        return failures;
7b6ff45c39ce 8010430: Math.round has surprising behavior for odd values of ulp 1
bpb
parents: 9269
diff changeset
   164
    }
9269
f66626469aa8 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2
darcy
parents:
diff changeset
   165
}