Java examples for java.lang:Math Calculation
Determines if value is powered by two.
//package com.java2s; public class Main { /**// www. j a va2s .c o m * Determines if value is powered by two. * * @param value * A value. * @return {@code true} if {@code value} is powered by two; otherwise {@code false}. */ public static boolean isPowerOfTwo(int value) { return (value > 0) && ((value & (value - 1)) == 0); } }