Judge whether a number is power of 2

View previous topic View next topic Go down

Judge whether a number is power of 2

Post  skyboard on Sat Oct 01, 2011 4:11 pm

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

skyboard

Posts : 31
Join date : 2011-09-03

View user profile

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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