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

Tagir F. Valeev tvaleev at openjdk.org
Mon Feb 6 08:46:54 UTC 2023


On Sun, 5 Feb 2023 18:13:35 GMT, ExE Boss <duke at openjdk.org> wrote:

>> Tagir F. Valeev has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Typo in doc fixed
>
> src/java.base/share/classes/java/lang/Math.java line 2213:
> 
>> 2211:      * @since 21
>> 2212:      */
>> 2213:     public static int clamp(long value, int min, int max) {
> 
> There should probably also be a pure `int` overload:
> 
> public static int clamp(int value, int min, int max)

@ExE-Boss which problem such an overload would solve? It looks like, `int clamp(long, int, int)` can be used everywhere where proposed `int clamp(int, int, int)` could be useful.

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

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


More information about the core-libs-dev mailing list