Click here to Skip to main content
15,885,216 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Answer[Removed] Pin
toxcct5-Mar-06 23:28
toxcct5-Mar-06 23:28 
GeneralRe: Power of 2 Pin
RichardS5-Mar-06 23:34
RichardS5-Mar-06 23:34 
GeneralRe: Power of 2 Pin
Cedric Moonen5-Mar-06 23:44
Cedric Moonen5-Mar-06 23:44 
GeneralRe: Power of 2 Pin
toxcct5-Mar-06 23:46
toxcct5-Mar-06 23:46 
GeneralRe: Power of 2 Pin
Stephen Hewitt5-Mar-06 23:45
Stephen Hewitt5-Mar-06 23:45 
GeneralRe: Power of 2 Pin
Stephen Hewitt6-Mar-06 2:04
Stephen Hewitt6-Mar-06 2:04 
GeneralRe: Power of 2 Pin
toxcct6-Mar-06 2:06
toxcct6-Mar-06 2:06 
AnswerRe: Power of 2 Pin
Russell'5-Mar-06 23:33
Russell'5-Mar-06 23:33 
if a number is a power of 2 than looking at the bits that composed that value must be all '0' but only one '1'.
So, if int is a 32 bit value, you can look for 31 '0' and 1 '1'.
But you need olso a loop! But it is quite fast.
Let me know if here is a faster bit function to count the ones/zeros

Bye

Have a nice code day Wink | ;)


GeneralRe: Power of 2 Pin
RichardS5-Mar-06 23:38
RichardS5-Mar-06 23:38 
GeneralRe: Power of 2 Pin
Russell'6-Mar-06 0:11
Russell'6-Mar-06 0:11 
QuestionRe: Power of 2 Pin
David Crow6-Mar-06 2:54
David Crow6-Mar-06 2:54 
AnswerRe: Power of 2 Pin
Russell'6-Mar-06 4:02
Russell'6-Mar-06 4:02 
GeneralRe: Power of 2 Pin
David Crow6-Mar-06 5:04
David Crow6-Mar-06 5:04 
AnswerRe: Power of 2 Pin
Divyang Mithaiwala5-Mar-06 23:45
Divyang Mithaiwala5-Mar-06 23:45 
GeneralRe: Power of 2 Pin
toxcct5-Mar-06 23:47
toxcct5-Mar-06 23:47 
GeneralRe: Power of 2 Pin
Divyang Mithaiwala6-Mar-06 0:25
Divyang Mithaiwala6-Mar-06 0:25 
GeneralRe: Power of 2 Pin
toxcct6-Mar-06 0:28
toxcct6-Mar-06 0:28 
GeneralRe: Power of 2 Pin
Divyang Mithaiwala5-Mar-06 23:51
Divyang Mithaiwala5-Mar-06 23:51 
AnswerRe: Power of 2 Pin
BadKarma5-Mar-06 23:51
BadKarma5-Mar-06 23:51 
AnswerRe: Power of 2 Pin
Taka Muraoka5-Mar-06 23:53
Taka Muraoka5-Mar-06 23:53 
GeneralRe: Power of 2 Pin
Ryan Binns6-Mar-06 0:15
Ryan Binns6-Mar-06 0:15 
AnswerRe: Power of 2 Pin
Ryan Binns5-Mar-06 23:59
Ryan Binns5-Mar-06 23:59 
GeneralRe: Power of 2 Pin
Stephen Hewitt6-Mar-06 0:13
Stephen Hewitt6-Mar-06 0:13 
GeneralRe: Power of 2 Pin
Ryan Binns6-Mar-06 0:16
Ryan Binns6-Mar-06 0:16 
GeneralRe: Power of 2 Pin
Stephen Hewitt6-Mar-06 0:18
Stephen Hewitt6-Mar-06 0:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.