On Thu, 8 Jul 2021 18:15:23 GMT, Brian Burkhalter <b...@openjdk.org> wrote:

>> Please consider this change to make the `float` and `double` versions of 
>> `java.lang.Math.abs()` branch-free.
>
> Brian Burkhalter has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   6506405: Add some tests

test/jdk/java/lang/Math/AbsTests.java line 35:

> 33:  */
> 34: public class AbsTests {
> 35:     private static final float  EULER_F   = (float)Math.exp(1.0);

Could use Math.E here instead.

test/jdk/java/lang/Math/AbsTests.java line 168:

> 166:     private static float testInRangeFloatAbs() {
> 167:         int errors = 0;
> 168:         float[][] testCases  = {

For the particulars of the test vector for abs, another way to structure this 
would be a 1-D array of positive numbers where nested test loops used the test 
value and its negation as the input with the positive number as the expected 
value.

test/jdk/java/lang/Math/AbsTests.java line 198:

> 196:                            float argument, float expected) {
> 197:         float result = absFunc.apply(argument);
> 198:         if (result != expected) {

I suggest looking at some other math test for the "equivalent" test idiom so 
that NaNs could be used in the test vector.

-------------

PR: https://git.openjdk.java.net/jdk/pull/4711

Reply via email to