Click here to Skip to main content
15,884,388 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
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 
_Russell_ wrote:
...let me know how have a faster function.


This one benchmarks faster than the one you've shown:

unsigned long Next2Power(unsigned long x)
{
    x--;
    x |= x >> 1;
    x |= x >> 2;
    x |= x >> 4;
    x |= x >> 8;
    x |= x >> 16;
    x++;

    return x;
}



"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

"There is no death, only a change of worlds." - Native American Proverb


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 
GeneralRe: Power of 2 Pin
Ryan Binns6-Mar-06 0:19
Ryan Binns6-Mar-06 0:19 
GeneralRe: Power of 2 Pin
Stephen Hewitt6-Mar-06 0:22
Stephen Hewitt6-Mar-06 0:22 
GeneralRe: Power of 2 Pin
Ryan Binns6-Mar-06 0:23
Ryan Binns6-Mar-06 0:23 
GeneralRe: Power of 2 Pin
Nibu babu thomas6-Mar-06 0:15
Nibu babu thomas6-Mar-06 0:15 
GeneralRe: Power of 2 Pin
Ryan Binns6-Mar-06 0:17
Ryan Binns6-Mar-06 0:17 

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.