Hi, igniters!
I noticed that the method "IgniteUtils.ceilPow2" can overflow for values
greater than 2^30 and return Integer.MIN_VALUE for them.
Maybe this check was skipped for method speed. In this case, we need to
add information about this into javaDoc.
Current implementation:
public static int ceilPow2(int v) {
return Integer.highestOneBit(v - 1) << 1;
}
It can be fixed like this:
bit impl:
int i = v - 1;
return Integer.highestOneBit(i) << 1 - (i >>> 30 ^ v >> 31);
more readable impl:
if (v == Integer.MIN_VALUE)
return 0;
int pow30 = 1 << 30;
return v >= pow30 ? pow30 : Integer.highestOneBit(v - 1) << 1;
What do you think? Sould I create ticket with PR?
--
Best Regards,
Vitaliy Biryukov