code: public static long roundUpPow2(long a) {
          if (a <= 0) {
              return 1;
          } else if (a > 0x4000000000000000L) {
              throw new IllegalArgumentException("Rounding " + a + " to the next highest power of two would exceed the int range");
          } else {
              a--;
              a |= a >> 1;
              a |= a >> 2;
              a |= a >> 4;
              a |= a >> 8;
              a |= a >> 16;
              a |= a >> 32;
              a++;
              return a;
          }
      }
docs: Rounds an integer up to the next power of 2.
  
  @param a The long to round
  @return the lowest power of 2 greater or equal to 'a'