Java Power of 2 nextPowerOf2(int x)

Here you can find the source of nextPowerOf2(int x)

Description

next Power Of

License

Open Source License

Declaration

public static int nextPowerOf2(int x) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int nextPowerOf2(int x) {
        return 1 << (x == 0 ? 0 : 32 - Integer.numberOfLeadingZeros(x - 1));
    }//from   w w w . j  a va  2 s  .c o  m
}

Related

  1. nextPowerOf2(int n)
  2. nextPowerOf2(int n)
  3. nextPowerOf2(int n)
  4. nextPowerOf2(int n)
  5. nextPowerOf2(int v)
  6. nextPowerOf2(int x)
  7. nextPowerOfTwo(final int targetSize)
  8. nextPowerOfTwo(final long nValue)
  9. nextPowerOfTwo(int i)