Pull to refresh
1
0
Send message
Да, действительно. Тогда вот так (а если ни один из аргументов не может быть нулем, то еще проще):

    protected static int calculateShift(int minimumValue, int maximumValue)
    {
        int target = Math.min(minimumValue, maximumValue);
        if (target > 0)
            return 32 - Integer.numberOfLeadingZeros(target - 1);
        else
            return 0;
    }
Как-то так:
protected static int calculateShift(int minimumValue, int maximumValue) {
  int target = Math.min(minimumValue, maximumValue);	
  if (target > 1)
    return Integer.highestOneBit(target - 1) << 1;
  else
    return 1;
}

Information

Rating
Does not participate
Registered
Activity