code: public static long nextPowerOf2(long num) {
      final long highBit = Long.highestOneBit(num);
      return (highBit == num) ? num : highBit << 1;
    }
docs: Returns the next number greater or equal num that is power of 2.