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

Raffaello Giulietti rgiulietti at openjdk.org
Mon Feb 13 17:14:34 UTC 2023


On Mon, 13 Feb 2023 17:05:06 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

>> Tagir F. Valeev has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Comments in tests
>
> Just a small point:
> 
>> Using similar approach in other cases (e.g. `float clamp(double, float, float))` may cause accidental precision loss even if the value is within range
> 
> May I ask at which values of the parameters does this occur? AFAIU, every `float` may be represented exactly by a `double`, which is the same situation with `long` and `int`.

@merykitty That clamp method would round a `double` to a `float`, an accidental precision loss.

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

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


More information about the core-libs-dev mailing list