JDK-8271599 : Javadoc of floorDiv() and floorMod() families is inaccurate in some places
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 8,11,16
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2021-08-01
  • Updated: 2021-08-17
  • Resolved: 2021-08-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 18
18 b10Fixed
Related Reports
Blocks :  
CSR :  
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
Errata in floorDiv(int, int), floorDiv(long, int) and floorDiv(long, long)
----
"The floor rounding mode gives different results from truncation when the exact result is negative."
shall be replaced with:
"The floor rounding mode gives different results from truncation when the exact result is [[not integer and]] negative."


Errata in floorDiv(int, int)
----
"If the signs of the arguments are the same, the results..."
shall be replaced with:
"If the signs of the arguments are the same [[or x is zero]], the results..."

Errata in floorDiv(int, int)
----
"If the signs of the arguments are different, the quotient is negative and floorDiv returns the integer less than or equal to ..."
shall be replaced with:
"If the signs of the arguments are different [[and x is not zero]], the quotient is negative and floorDiv returns the [[largest]] integer less than or equal to ..."



Errata in floorMod(int, int), floorMod(long, int) and floorMod(long, long)
----
"The floor modulus is x - (floorDiv(x, y) * y), has the same sign as the divisor y, and..."
shall be replaced with:
"The floor modulus is [[r =]] x - (floorDiv(x, y) * y), has the same sign as the divisor y [[or is zero]], and..."

Errata in floorMod(int, int)
----
"that returns the integer less than or equal to..."
shall be replaced with:
"that returns the [[largest]] integer less than or equal to..."

Errata in floorMod(int, int)
----
"If the signs of the arguments are the same, the results..."
shall be replaced with:
"If the signs of the arguments are the same [[or x is zero]], the results..."

Errata in floorMod(int, int)
----
"If the signs of the arguments are different, the results..."
shall be replaced with:
"If the signs of the arguments are different [[and x is not zero]], the results..."

Errata in floorMod(int, int)
----
"If the signs of arguments are unknown..."
shall be removed, as it might lead to erroneous results due to overflow in the sum.





FREQUENCY : always



Comments
The submitter confirmed the fix.
17-08-2021

Requested the submitter review the fix https://git.openjdk.java.net/jdk/commit/9f1edafac4f096977ea6ce075ae7a6b0c2112b7d
17-08-2021

Changeset: 9f1edafa Author: Raffaello Giulietti <raffaello.giulietti@gmail.com> Committer: Brian Burkhalter <bpb@openjdk.org> Date: 2021-08-04 17:16:40 +0000 URL: https://git.openjdk.java.net/jdk/commit/9f1edafac4f096977ea6ce075ae7a6b0c2112b7d
04-08-2021

The errata can be found at: https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/Math.java#L1301 https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/Math.java#L1261 https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/Math.java#L1264 https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/Math.java#L1356 https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/Math.java#L1368 https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/Math.java#L1373 https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/Math.java#L1379 https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/Math.java#L1388
02-08-2021