RFR: 8301226: Add clamp() methods to java.lang.Math and to StrictMath [v4]

Tagir F. Valeev tvaleev at openjdk.org
Tue Feb 7 10:24:25 UTC 2023


On Tue, 7 Feb 2023 00:57:54 GMT, Joe Darcy <darcy at openjdk.org> wrote:

>> Tagir F. Valeev has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Added explanatory comments
>
> src/java.base/share/classes/java/lang/Math.java line 2266:
> 
>> 2264:         // If min == max, we should additionally check for +0.0/-0.0 case,
>> 2265:         // so we're still visiting the if statement.
>> 2266:         if (!(min < max)) {
> 
> A suggestion for an additional comment on this line like:
> 
> // min greater than, equal to, or unordered with respect to max; NaN values are unorded

Added, thanks!

> test/jdk/java/lang/Math/Clamp.java line 47:
> 
>> 45:     private static int testIntClamp() {
>> 46:         int failures = 0;
>> 47:         failures += checkIntClamp(0, 1, 2, 1);
> 
> Possible refactoring here: represent the test cases in, say, a 2D int array or an array/list of records and loop over them.

Updated. Is it better this way?

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

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


More information about the core-libs-dev mailing list