RFR: JDK-8302028: Port fdlibm atan2 to Java [v2]

Joe Darcy darcy at openjdk.org
Fri Feb 17 19:36:13 UTC 2023


On Fri, 17 Feb 2023 14:02:35 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> Joe Darcy has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
>> 
>>  - Update regression test.
>>  - Merge branch 'master' into JDK-8302028
>>  - JDK-8302028: Port fdlibm atan2 to Java
>
> src/java.base/share/classes/java/lang/FdLibm.java line 458:
> 
>> 456:                 case 0, 1 ->  y;              // atan(+/-0, +anything)  = +/-0
>> 457:                 case 2    ->  Math.PI + tiny; // atan(+0,   -anything)  =  pi
>> 458:                 default   -> -Math.PI - tiny; // atan(-0,   -anything)  = -pi
> 
> The original switch statement and this switch expression are semantically equivalent only because of our knowledge that `m` can only assume values 0, 1, 2, or 3. This requires more reasoning than a more verbatim copy of the original statement. Not sure if it is worth.
> 
> The same holds for the switch expressions below.

Yes, the use of switch expressions here is certainly not strictly necessary.

Something that helped convince me it was okay was that the final switch on m in atan2 uses the set of case labels {0, 1, 2, default}., further implying that m can only take on the values {0, 1, 2, 3}.

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

PR: https://git.openjdk.org/jdk/pull/12608


More information about the core-libs-dev mailing list