test/java/lang/Math/Log10Tests.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2003, 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) 2003, 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.
*** 26,36 ****
* @bug 4074599 4939441
* @summary Tests for {Math, StrictMath}.log10
* @author Joseph D. Darcy
*/
- import sun.misc.FpUtils;
import sun.misc.DoubleConsts;
public class Log10Tests {
private Log10Tests(){}
--- 26,35 ----
*** 96,112 ****
// Test for gross inaccuracy by comparing to log; should be
// within a few ulps of log(x)/log(10)
for(int i = 0; i < 10000; i++) {
double input = Double.longBitsToDouble(rand.nextLong());
! if(! FpUtils.isFinite(input))
continue; // avoid testing NaN and infinite values
else {
input = Math.abs(input);
double expected = StrictMath.log(input)/LN_10;
! if( ! FpUtils.isFinite(expected))
continue; // if log(input) overflowed, try again
else {
double result;
if( Math.abs(((result=Math.log10(input)) - expected)/Math.ulp(expected)) > 3) {
--- 95,111 ----
// Test for gross inaccuracy by comparing to log; should be
// within a few ulps of log(x)/log(10)
for(int i = 0; i < 10000; i++) {
double input = Double.longBitsToDouble(rand.nextLong());
! if(! Double.isFinite(input))
continue; // avoid testing NaN and infinite values
else {
input = Math.abs(input);
double expected = StrictMath.log(input)/LN_10;
! if( ! Double.isFinite(expected))
continue; // if log(input) overflowed, try again
else {
double result;
if( Math.abs(((result=Math.log10(input)) - expected)/Math.ulp(expected)) > 3) {
*** 152,170 ****
double down = Double.NaN;
for(int i = 0; i < half; i++) {
if (i == 0) {
input[half] = 1.0;
up = Math.nextUp(1.0);
! down = FpUtils.nextDown(1.0);
} else {
input[half + i] = up;
input[half - i] = down;
up = Math.nextUp(up);
! down = FpUtils.nextDown(down);
}
}
! input[0] = FpUtils.nextDown(input[1]);
for(int i = 0; i < neighbors.length; i++) {
neighbors[i] = Math.log10(input[i]);
neighborsStrict[i] = StrictMath.log10(input[i]);
--- 151,169 ----
double down = Double.NaN;
for(int i = 0; i < half; i++) {
if (i == 0) {
input[half] = 1.0;
up = Math.nextUp(1.0);
! down = Math.nextDown(1.0);
} else {
input[half + i] = up;
input[half - i] = down;
up = Math.nextUp(up);
! down = Math.nextDown(down);
}
}
! input[0] = Math.nextDown(input[1]);
for(int i = 0; i < neighbors.length; i++) {
neighbors[i] = Math.log10(input[i]);
neighborsStrict[i] = StrictMath.log10(input[i]);