code: public static int nextPOT (int value) {
      assert value < 0x10000;
      int bit = 0x8000, highest = -1, count = 0;
      for (int ii = 15; ii >= 0; ii--, bit >>= 1) {
        if ((value & bit) == 0) continue;
        count++;
        if (highest == -1) highest = ii;
      }
      return (count > 1) ? (1 << (highest+1)) : value;
    }
docs: Returns next largest power of two, or {@code value} if {@code value} is already a POT. Note:
  this is limited to values less than {@code 0x10000}.