2 ms·
How to check if a number is power of Two in Java
- ColinWright 13y agoThere are just so many things wrong with this article I don't know where to start. I've seen at least one error, one incorrect description, and this code: if ((number & -number) == number) { return true; } return false; It would be a more interesting interview question to get a candidate to analyze these examples, rather than trying to solve the problem.