code: public static int NextPowerOf2(int x) {
          --x;
          x |= x >> 1;
          x |= x >> 2;
          x |= x >> 4;
          x |= x >> 8;
          x |= x >> 16;
          return ++x;
      }
docs: Returns the next power of 2 after the input value x.
  
  @param x Input value x.
  @return Returns the next power of 2 after the input value x.