Java examples for java.lang:Math Calculation
is Power Of 2
//package com.java2s; public class Main { public static boolean isPowerOf2(int n) { boolean isPowerOf2; if (n <= 0 || (n - 1 & n) != 0) { isPowerOf2 = false;/*from w ww . ja v a2s .c o m*/ } else { isPowerOf2 = true; } return isPowerOf2; } }