JDK-8271602 : Add Math.ceilDiv() family parallel to Math.floorDiv() family
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 16
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2021-08-01
  • Updated: 2022-04-27
  • Resolved: 2021-09-22
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 b16Fixed
Related Reports
CSR :  
Duplicate :  
Description
A DESCRIPTION OF THE PROBLEM :
j.l.Math only exposes a floorDiv() family and not a ceilDiv() family as well.

When determining how many blocks of size n are minimally needed to host m items, for example, the computation behind the scenes is something akin to ceilDiv(m, n). I guess there are many customized ceilDiv()-like computations in the code base, probably some of them incorrect at the extrema of the int/long ranges. Thus, an official ceilDiv() family is certainly helpful.




Comments
The submitter was me, before I had author status to submit issues on the JBS by myself. I also authored the fix.
10-10-2021

Requested the submitter verify the fix by downloading the latest version of JDK 18 from https://jdk.java.net/18/
10-10-2021

Changeset: da38ced3 Author: Raffaello Giulietti <raffaello.giulietti@gmail.com> Committer: Brian Burkhalter <bpb@openjdk.org> Date: 2021-09-22 16:16:14 +0000 URL: https://git.openjdk.java.net/jdk/commit/da38ced3299cbd02f210bea4130990a43f6104bf
22-09-2021

I planned to file another issue waiting for JDK-8271225 to be approved, Now that it is, I'll extend this issue and its CSR with ceilDivExact() as you suggest.
31-08-2021

Perhaps the scope of this issue should be expanded to include ceilDivExact() analogs of the methods to be added by the commit resolving JDK-8271225?
30-08-2021

Moved to JDK to get more evaluations to add proposed features.
02-08-2021