Code For NonGeek
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Judge whether a number is power of 2

Go down

Judge whether a number is power of 2 Empty Judge whether a number is power of 2

Post  skyboard Sat Oct 01, 2011 4:11 pm

bool IsPowerOf2( int value )
{
return ! (value & ( value - 1 ) );
}

skyboard

Posts : 31
Join date : 2011-09-03

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum