Check whether an integer is a power of 2 without using +,- operations
Write a program that checks if the integer is a power of 2.
JavaScript
// See http://codegolf.stackexchange.com/questions/17456/check-whether-an-integer-is-a-power-of-2-without-using-operations
function isDivisibleByTwo()
{
var r = Math.log(prompt())/Math.log(2);
alert(r>0 && ~~r==r);
}
isDivisibleByTwo();