RFR: 8240632: Note differences between IEEE 754-2019 math lib special cases and java.lang.Math
Recent revisions of the IEEE 754 floating-point standard have added guidance on how typical math library methods (sin, cos, tan, etc.) should behave in terms of their general quality of implementation as well as on special values. Other than the pow methods, for the recommended operations listed by IEEE 754 that the Java math library already includes, the special cases that are specified by Java are the same as those specified by IEEE 754, except for the pow method. IEEE 754 calls out some special cases not explicitly listed in the Java specs. This changeset adds those special cases to the spec and adds tests of the the special cases if not already present. If method "Foo" already had a regression test, new cases were added it it. Otherwise, a new test was added to cover the special cases of several methods. There is no intention at the moment to change the behavior of pow to align with IEEE 754. ------------- Commit messages: - Initial changes for JDK-8240632. Changes: https://git.openjdk.java.net/jdk/pull/2395/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2395&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8240632 Stats: 223 lines in 5 files changed: 212 ins; 0 del; 11 mod Patch: https://git.openjdk.java.net/jdk/pull/2395.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/2395/head:pull/2395 PR: https://git.openjdk.java.net/jdk/pull/2395
On Thu, 4 Feb 2021 02:08:12 GMT, Joe Darcy <darcy@openjdk.org> wrote:
Recent revisions of the IEEE 754 floating-point standard have added guidance on how typical math library methods (sin, cos, tan, etc.) should behave in terms of their general quality of implementation as well as on special values.
Other than the pow methods, for the recommended operations listed by IEEE 754 that the Java math library already includes, the special cases that are specified by Java are the same as those specified by IEEE 754, except for the pow method. IEEE 754 calls out some special cases not explicitly listed in the Java specs. This changeset adds those special cases to the spec and adds tests of the the special cases if not already present.
If method "Foo" already had a regression test, new cases were added it it. Otherwise, a new test was added to cover the special cases of several methods.
There is no intention at the moment to change the behavior of pow to align with IEEE 754.
PS After the wording for the Math class is finalized, I'll add analogous wording to the StrictMath class and run a CSR. ------------- PR: https://git.openjdk.java.net/jdk/pull/2395
Recent revisions of the IEEE 754 floating-point standard have added guidance on how typical math library methods (sin, cos, tan, etc.) should behave in terms of their general quality of implementation as well as on special values.
Other than the pow methods, for the recommended operations listed by IEEE 754 that the Java math library already includes, the special cases that are specified by Java are the same as those specified by IEEE 754, except for the pow method. IEEE 754 calls out some special cases not explicitly listed in the Java specs. This changeset adds those special cases to the spec and adds tests of the the special cases if not already present.
If method "Foo" already had a regression test, new cases were added it it. Otherwise, a new test was added to cover the special cases of several methods.
There is no intention at the moment to change the behavior of pow to align with IEEE 754.
Joe Darcy has updated the pull request incrementally with one additional commit since the last revision: Correct acos spec and fix regression test. ------------- Changes: - all: https://git.openjdk.java.net/jdk/pull/2395/files - new: https://git.openjdk.java.net/jdk/pull/2395/files/052cfb30..efd606ff Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=2395&range=01 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=2395&range=00-01 Stats: 11 lines in 2 files changed: 0 ins; 5 del; 6 mod Patch: https://git.openjdk.java.net/jdk/pull/2395.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/2395/head:pull/2395 PR: https://git.openjdk.java.net/jdk/pull/2395
On Thu, 4 Feb 2021 18:30:57 GMT, Joe Darcy <darcy@openjdk.org> wrote:
Recent revisions of the IEEE 754 floating-point standard have added guidance on how typical math library methods (sin, cos, tan, etc.) should behave in terms of their general quality of implementation as well as on special values.
Other than the pow methods, for the recommended operations listed by IEEE 754 that the Java math library already includes, the special cases that are specified by Java are the same as those specified by IEEE 754, except for the pow method. IEEE 754 calls out some special cases not explicitly listed in the Java specs. This changeset adds those special cases to the spec and adds tests of the the special cases if not already present.
If method "Foo" already had a regression test, new cases were added it it. Otherwise, a new test was added to cover the special cases of several methods.
There is no intention at the moment to change the behavior of pow to align with IEEE 754.
Joe Darcy has updated the pull request incrementally with one additional commit since the last revision:
Correct acos spec and fix regression test.
src/java.base/share/classes/java/lang/Math.java line 237:
235: * <ul><li>If the argument is NaN or its absolute value is greater 236: * than 1, then the result is NaN. 237: * <li>If the argument is {@code 1.0}, the result is {@code +0.0}.
`+0.0` is used here but in several cases below it is written out as `positive zero`. src/java.base/share/classes/java/lang/Math.java line 716:
714: * the infinite power as a large integer (large-magnitude 715: * floating-point numbers are numerically integers, specifically 716: * even integer) and therefore specifies {@code 1.0} be returned.
In this sentence `integer` should be plural. ------------- PR: https://git.openjdk.java.net/jdk/pull/2395
Recent revisions of the IEEE 754 floating-point standard have added guidance on how typical math library methods (sin, cos, tan, etc.) should behave in terms of their general quality of implementation as well as on special values.
Other than the pow methods, for the recommended operations listed by IEEE 754 that the Java math library already includes, the special cases that are specified by Java are the same as those specified by IEEE 754, except for the pow method. IEEE 754 calls out some special cases not explicitly listed in the Java specs. This changeset adds those special cases to the spec and adds tests of the the special cases if not already present.
If method "Foo" already had a regression test, new cases were added it it. Otherwise, a new test was added to cover the special cases of several methods.
There is no intention at the moment to change the behavior of pow to align with IEEE 754.
Joe Darcy has updated the pull request incrementally with one additional commit since the last revision: Respond to review comments. ------------- Changes: - all: https://git.openjdk.java.net/jdk/pull/2395/files - new: https://git.openjdk.java.net/jdk/pull/2395/files/efd606ff..0c6134d1 Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=2395&range=02 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=2395&range=01-02 Stats: 53 lines in 3 files changed: 36 ins; 0 del; 17 mod Patch: https://git.openjdk.java.net/jdk/pull/2395.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/2395/head:pull/2395 PR: https://git.openjdk.java.net/jdk/pull/2395
On Sun, 7 Feb 2021 00:45:03 GMT, Joe Darcy <darcy@openjdk.org> wrote:
Recent revisions of the IEEE 754 floating-point standard have added guidance on how typical math library methods (sin, cos, tan, etc.) should behave in terms of their general quality of implementation as well as on special values.
Other than the pow methods, for the recommended operations listed by IEEE 754 that the Java math library already includes, the special cases that are specified by Java are the same as those specified by IEEE 754, except for the pow method. IEEE 754 calls out some special cases not explicitly listed in the Java specs. This changeset adds those special cases to the spec and adds tests of the the special cases if not already present.
If method "Foo" already had a regression test, new cases were added it it. Otherwise, a new test was added to cover the special cases of several methods.
There is no intention at the moment to change the behavior of pow to align with IEEE 754.
Joe Darcy has updated the pull request incrementally with one additional commit since the last revision:
Respond to review comments.
Marked as reviewed by bpb (Reviewer). ------------- PR: https://git.openjdk.java.net/jdk/pull/2395
On Thu, 4 Feb 2021 02:08:12 GMT, Joe Darcy <darcy@openjdk.org> wrote:
Recent revisions of the IEEE 754 floating-point standard have added guidance on how typical math library methods (sin, cos, tan, etc.) should behave in terms of their general quality of implementation as well as on special values.
Other than the pow methods, for the recommended operations listed by IEEE 754 that the Java math library already includes, the special cases that are specified by Java are the same as those specified by IEEE 754, except for the pow method. IEEE 754 calls out some special cases not explicitly listed in the Java specs. This changeset adds those special cases to the spec and adds tests of the the special cases if not already present.
If method "Foo" already had a regression test, new cases were added it it. Otherwise, a new test was added to cover the special cases of several methods.
There is no intention at the moment to change the behavior of pow to align with IEEE 754.
This pull request has now been integrated. Changeset: 2fd8ed02 Author: Joe Darcy <darcy@openjdk.org> URL: https://git.openjdk.java.net/jdk/commit/2fd8ed02 Stats: 264 lines in 5 files changed: 243 ins; 0 del; 21 mod 8240632: Note differences between IEEE 754-2019 math lib special cases and java.lang.Math Reviewed-by: bpb ------------- PR: https://git.openjdk.java.net/jdk/pull/2395
participants (2)
-
Brian Burkhalter
-
Joe Darcy