RFR: 6506405: Math.abs(float) is slow [v5]
Brian Burkhalter
bpb at openjdk.java.net
Fri Jul 9 17:27:20 UTC 2021
On Fri, 9 Jul 2021 13:54:39 GMT, Joe Darcy <darcy at openjdk.org> wrote:
>> 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.
Yeah that was lame.
> 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.
Changed to 1-D array but can be either positive or negative.
> 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.
Added `NaN` check in latest update but might be suspect.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4711
More information about the core-libs-dev
mailing list