Judge whether a number is power of 2
Page 1 of 1
Judge whether a number is power of 2
bool IsPowerOf2( int value )
{
return ! (value & ( value - 1 ) );
}
{
return ! (value & ( value - 1 ) );
}
skyboard- Posts : 31
Join date : 2011-09-03
Similar topics
» Given a magic number sum, to find if there are two numbers whose sum equals to the number
» Count number of 1's in Java
» An array of integers, all appear twice except one, find this number.
» Given a two dimensional graph with points on it, fin a line which passes the most number of points
» print all subsets of an array whose sum equals one number
» Count number of 1's in Java
» An array of integers, all appear twice except one, find this number.
» Given a two dimensional graph with points on it, fin a line which passes the most number of points
» print all subsets of an array whose sum equals one number
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|