## test/java/lang/Math/Log10Tests.java

 ``` `````` 136 { 137 double neighbors[] = new double[40]; 138 double neighborsStrict[] = new double[40]; 139 double z = Double.NaN; 140 141 // Test inputs greater than 1.0. 142 neighbors[0] = Math.log10(1.0); 143 neighborsStrict[0] = StrictMath.log10(1.0); 144 145 double input[] = new double[40]; 146 int half = input.length/2; 147 148 149 // Initialize input to the 40 consecutive double values 150 // "centered" at 1.0. 151 double up = Double.NaN; 152 double down = Double.NaN; 153 for(int i = 0; i < half; i++) { 154 if (i == 0) { 155 input[half] = 1.0; 156 up = FpUtils.nextUp(1.0); 157 down = FpUtils.nextDown(1.0); 158 } else { 159 input[half + i] = up; 160 input[half - i] = down; 161 up = FpUtils.nextUp(up); 162 down = FpUtils.nextDown(down); 163 } 164 } 165 input[0] = FpUtils.nextDown(input[1]); 166 167 for(int i = 0; i < neighbors.length; i++) { 168 neighbors[i] = Math.log10(input[i]); 169 neighborsStrict[i] = StrictMath.log10(input[i]); 170 171 // Test accuracy. 172 z = input[i] - 1.0; 173 double expected = (z - (z*z)*0.5)/LN_10; 174 if ( Math.abs(neighbors[i] - expected ) > 3*Math.ulp(expected) ) { 175 failures++; 176 System.err.println("For input near 1.0 " + input[i] + 177 ", Math.log10(1+z) was more than 3 ulps different from " + 178 "(z-(z^2)/2)/ln(10): log10(input) = " + neighbors[i] + 179 "\texpected about = " + expected); 180 } 181 ``` ``` `````` 136 { 137 double neighbors[] = new double[40]; 138 double neighborsStrict[] = new double[40]; 139 double z = Double.NaN; 140 141 // Test inputs greater than 1.0. 142 neighbors[0] = Math.log10(1.0); 143 neighborsStrict[0] = StrictMath.log10(1.0); 144 145 double input[] = new double[40]; 146 int half = input.length/2; 147 148 149 // Initialize input to the 40 consecutive double values 150 // "centered" at 1.0. 151 double up = Double.NaN; 152 double down = Double.NaN; 153 for(int i = 0; i < half; i++) { 154 if (i == 0) { 155 input[half] = 1.0; 156 up = Math.nextUp(1.0); 157 down = FpUtils.nextDown(1.0); 158 } else { 159 input[half + i] = up; 160 input[half - i] = down; 161 up = Math.nextUp(up); 162 down = FpUtils.nextDown(down); 163 } 164 } 165 input[0] = FpUtils.nextDown(input[1]); 166 167 for(int i = 0; i < neighbors.length; i++) { 168 neighbors[i] = Math.log10(input[i]); 169 neighborsStrict[i] = StrictMath.log10(input[i]); 170 171 // Test accuracy. 172 z = input[i] - 1.0; 173 double expected = (z - (z*z)*0.5)/LN_10; 174 if ( Math.abs(neighbors[i] - expected ) > 3*Math.ulp(expected) ) { 175 failures++; 176 System.err.println("For input near 1.0 " + input[i] + 177 ", Math.log10(1+z) was more than 3 ulps different from " + 178 "(z-(z^2)/2)/ln(10): log10(input) = " + neighbors[i] + 179 "\texpected about = " + expected); 180 } 181 ```