next Power Of Two by shifting - Android java.lang

Android examples for java.lang:Math

Description

next Power Of Two by shifting

Demo Code


//package com.java2s;

public class Main {
    static public int nextPowerOfTwo(int value) {
        return 1 << (32 - Integer.numberOfLeadingZeros(value - 1));
    }/*from w ww  .ja  va  2 s.c  o m*/
}

Related Tutorials