How to find whether a Number is a power of 2 or not in Java?There can be many possible solutions to this problem, but probably the most efficient remains to be the one which uses bit-level manipulation wisely.We'll talk about only that solution here and since it involves bit-level manipulation of binary sequences, so should you require a refresh, first go through this article - 2's complement, 1'
This post first appeared on Geek Explains: Java, J2EE, Oracle, Puzzles, And Problem Solving!, please read the originial post: here