On Fri, 18 Jul 2025 18:08:34 GMT, Andy Goryachev <ango...@openjdk.org> wrote:

>> Changed accordingly and included another check to verify if the `val` is 
>> already a power of two.
>
> This code (in my experience) is easy to get wrong.
> Could we add some tests, to verify that
> - values within the allowed range (small and large) work as expected
> - values outside of the allowed range fail as expected
> - power of 2 values are returned unchanged

also, there might be an alternative without a loop:

int v = Integer.highestOneBit(value);
if(v == value) {
  return value;
}
return v << 1;

I don't know how frequent this operation is, but the loop makes me sad.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1824#discussion_r2216639191

Reply via email to