find power of 2 in java code example
Example 1: how to find power of a number in java
int powerOfNumber = (int) Math.pow(number, power);
Example 2: java is power of 2
boolean result = number > 0 && ((number & (number - 1)) == 0);
int powerOfNumber = (int) Math.pow(number, power);
boolean result = number > 0 && ((number & (number - 1)) == 0);