code: public static int nextPow2(int x) {
  		if (x < 1)
  			throw new IllegalArgumentException("x must be greater or equal 1");
  		if ((x & (x - 1)) == 0) {
  			if( x == 1 )
  				return 2;
  			return x; // x is already a power-of-two number
  		}
  		x |= (x >>> 1);
  		x |= (x >>> 2);
  		x |= (x >>> 4);
  		x |= (x >>> 8);
  		x |= (x >>> 16);
  		x |= (x >>> 32);
  		return x + 1;
  	}
docs: Returns the closest power-of-two number greater than or equal to x.
  
  @param x
  @return the closest power-of-two number greater than or equal to x