Java Power of 2 nextPowerOfTwo(int i)

Here you can find the source of nextPowerOfTwo(int i)

Description

next Power Of Two

License

Open Source License

Declaration

private static int nextPowerOfTwo(int i) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static int nextPowerOfTwo(int i) {
        int minusOne = i - 1;
        minusOne |= minusOne >> 1;
        minusOne |= minusOne >> 2;
        minusOne |= minusOne >> 4;
        minusOne |= minusOne >> 8;
        minusOne |= minusOne >> 16;
        return minusOne + 1;
    }/*from  w  w w .  jav a  2 s  .c  o m*/
}

Related

  1. nextPowerOf2(int x)
  2. nextPowerOfTwo(final int targetSize)
  3. nextPowerOfTwo(final long nValue)
  4. nextPowerOfTwo(int i)
  5. nextPowerOfTwo(int i)
  6. nextPowerOfTwo(int n)
  7. nextPowerOfTwo(int num)
  8. nextPowerOfTwo(int value)
  9. nextPowerOfTwo(int value)