RFR: 8271602: Add Math.ceilDiv() family parallel to Math.floorDiv() family

Brian Burkhalter bpb at openjdk.java.net
Mon Aug 30 23:11:33 UTC 2021


On Fri, 27 Aug 2021 18:53:23 GMT, Raffaello Giulietti <github.com+70726043+rgiulietti at openjdk.org> wrote:

> Please review this PR to add officially endorsed `ceilDiv()` and `ceilMod()` methods do `j.l.[Strict]Math`.
> 
> Beside adding fresh tests to `test/jdk/java/lang/Math/DivModTests.java`, this PR also corrects small typos in it and exercises tests that were already present but which were never invoked.
> Let me know if this is acceptable for a test or if there's a need of a separate issue in the JBS.

src/java.base/share/classes/java/lang/Math.java line 1589:

> 1587:      * <ul>
> 1588:      *   <li>Regardless of the signs of the arguments, {@code ceilMod}(x, y)
> 1589:      *       is zero exactly when {@code x % y} is zero as well.</li>

Do you intend to say "`ceilMod(x, y)` is zero if and only if `x % y` is zero"? That is to say "exactly when" intends "if and only if"?

src/java.base/share/classes/java/lang/Math.java line 1591:

> 1589:      *       is zero exactly when {@code x % y} is zero as well.</li>
> 1590:      *   <li>If neither of {@code ceilMod}(x, y) or {@code x % y} is zero,
> 1591:      *       their results differ exactly when the signs of the arguments are the same.<br>

I would say "If neither `ceilMod(x, y)`nor `x % y` is zero".  Also same question as above: by "exactly when" do you intend "if any only if"?

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

PR: https://git.openjdk.java.net/jdk/pull/5285


More information about the core-libs-dev mailing list