test/java/lang/Math/CeilAndFloorTests.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 25,35 **** * @test * @bug 6908131 * @summary Check for correct implementation of Math.ceil and Math.floor */ - import sun.misc.FpUtils; import sun.misc.DoubleConsts; public class CeilAndFloorTests { private static int testCeilCase(double input, double expected) { int failures = 0; --- 25,34 ----
*** 67,77 **** failures += testFloorCase(fixedPoint, fixedPoint); } for(int i = Double.MIN_EXPONENT; i <= Double.MAX_EXPONENT; i++) { double powerOfTwo = Math.scalb(1.0, i); ! double neighborDown = FpUtils.nextDown(powerOfTwo); double neighborUp = Math.nextUp(powerOfTwo); if (i < 0) { failures += testCeilCase( powerOfTwo, 1.0); failures += testCeilCase(-powerOfTwo, -0.0); --- 66,76 ---- failures += testFloorCase(fixedPoint, fixedPoint); } for(int i = Double.MIN_EXPONENT; i <= Double.MAX_EXPONENT; i++) { double powerOfTwo = Math.scalb(1.0, i); ! double neighborDown = Math.nextDown(powerOfTwo); double neighborUp = Math.nextUp(powerOfTwo); if (i < 0) { failures += testCeilCase( powerOfTwo, 1.0); failures += testCeilCase(-powerOfTwo, -0.0);
*** 112,122 **** } } for(int i = -(0x10000); i <= 0x10000; i++) { double d = (double) i; ! double neighborDown = FpUtils.nextDown(d); double neighborUp = Math.nextUp(d); failures += testCeilCase( d, d); failures += testCeilCase(-d, -d); --- 111,121 ---- } } for(int i = -(0x10000); i <= 0x10000; i++) { double d = (double) i; ! double neighborDown = Math.nextDown(d); double neighborUp = Math.nextUp(d); failures += testCeilCase( d, d); failures += testCeilCase(-d, -d);
*** 138,149 **** public static int roundingTests() { int failures = 0; double [][] testCases = { { Double.MIN_VALUE, 1.0}, {-Double.MIN_VALUE, -0.0}, ! { FpUtils.nextDown(DoubleConsts.MIN_NORMAL), 1.0}, ! {-FpUtils.nextDown(DoubleConsts.MIN_NORMAL), -0.0}, { DoubleConsts.MIN_NORMAL, 1.0}, {-DoubleConsts.MIN_NORMAL, -0.0}, { 0.1, 1.0}, {-0.1, -0.0}, --- 137,148 ---- public static int roundingTests() { int failures = 0; double [][] testCases = { { Double.MIN_VALUE, 1.0}, {-Double.MIN_VALUE, -0.0}, ! { Math.nextDown(DoubleConsts.MIN_NORMAL), 1.0}, ! {-Math.nextDown(DoubleConsts.MIN_NORMAL), -0.0}, { DoubleConsts.MIN_NORMAL, 1.0}, {-DoubleConsts.MIN_NORMAL, -0.0}, { 0.1, 1.0}, {-0.1, -0.0},
*** 155,184 **** {-1.5, -1.0}, { 2.5, 3.0}, {-2.5, -2.0}, ! { FpUtils.nextDown(1.0), 1.0}, ! { FpUtils.nextDown(-1.0), -1.0}, { Math.nextUp(1.0), 2.0}, { Math.nextUp(-1.0), -0.0}, { 0x1.0p51, 0x1.0p51}, {-0x1.0p51, -0x1.0p51}, ! { FpUtils.nextDown(0x1.0p51), 0x1.0p51}, {-Math.nextUp(0x1.0p51), -0x1.0p51}, { Math.nextUp(0x1.0p51), 0x1.0p51+1}, ! {-FpUtils.nextDown(0x1.0p51), -0x1.0p51+1}, ! { FpUtils.nextDown(0x1.0p52), 0x1.0p52}, {-Math.nextUp(0x1.0p52), -0x1.0p52-1.0}, { Math.nextUp(0x1.0p52), 0x1.0p52+1.0}, ! {-FpUtils.nextDown(0x1.0p52), -0x1.0p52+1.0}, }; for(double[] testCase : testCases) { failures += testCeilCase(testCase[0], testCase[1]); failures += testFloorCase(-testCase[0], -testCase[1]); --- 154,183 ---- {-1.5, -1.0}, { 2.5, 3.0}, {-2.5, -2.0}, ! { Math.nextDown(1.0), 1.0}, ! { Math.nextDown(-1.0), -1.0}, { Math.nextUp(1.0), 2.0}, { Math.nextUp(-1.0), -0.0}, { 0x1.0p51, 0x1.0p51}, {-0x1.0p51, -0x1.0p51}, ! { Math.nextDown(0x1.0p51), 0x1.0p51}, {-Math.nextUp(0x1.0p51), -0x1.0p51}, { Math.nextUp(0x1.0p51), 0x1.0p51+1}, ! {-Math.nextDown(0x1.0p51), -0x1.0p51+1}, ! { Math.nextDown(0x1.0p52), 0x1.0p52}, {-Math.nextUp(0x1.0p52), -0x1.0p52-1.0}, { Math.nextUp(0x1.0p52), 0x1.0p52+1.0}, ! {-Math.nextDown(0x1.0p52), -0x1.0p52+1.0}, }; for(double[] testCase : testCases) { failures += testCeilCase(testCase[0], testCase[1]); failures += testFloorCase(-testCase[0], -testCase[1]);