Skip to content
Snippets Groups Projects
Select Git revision
  • 87e5ca23e5b1af9dcbf1965e21b942e6b82f7e8f
  • master default
  • signal-final
  • multiple-ports-final
  • pipeline-with-method-call-final
5 results

Pow2.java

Blame
  • Pow2.java 327 B
    package teetime.util.concurrent.spsc;
    
    public class Pow2 {
    
    	private Pow2() {
    		// utility class
    	}
    
    	public static int findNextPositivePowerOfTwo(final int value) {
    		return 1 << (32 - Integer.numberOfLeadingZeros(value - 1));
    	}
    
    	public static boolean isPowerOf2(final int value) {
    		return (value & (value - 1)) == 0;
    	}
    }