Check if a number is a power of 2 or not
bool isPower2 ; if ( ( int ) ( Math . Ceiling ( ( Math . Log ( N ) / Math . Log ( N ) ) ) ) == ( int ) ( Math . Floor ( ( ( Math . Log ( N ) / Math . Log ( 2 ) ) ) ) ) ) { isPower2 = true ; } else { isPower2 = false ; }