Java Power of 2 nextPowerOfTwo(int num)

Here you can find the source of nextPowerOfTwo(int num)

Description

next Power Of Two

License

Open Source License

Declaration

public static int nextPowerOfTwo(int num) 

Method Source Code

//package com.java2s;

public class Main {
    public static int nextPowerOfTwo(int num) {
        int result = 1;
        while (num != 0) {
            num >>= 1;//  w  ww.ja  v  a2  s  .c om
            result <<= 1;
        }
        return result;
    }
}

Related

  1. nextPowerOfTwo(final long nValue)
  2. nextPowerOfTwo(int i)
  3. nextPowerOfTwo(int i)
  4. nextPowerOfTwo(int i)
  5. nextPowerOfTwo(int n)
  6. nextPowerOfTwo(int value)
  7. nextPowerOfTwo(int value)
  8. nextPowerOfTwo(int value)
  9. nextPowerOfTwo(int value)