The mystery function
-
This is a little game. Someone in CodeProject wrote this: I'll let you guess what this does and how it should be named:
static int f(int v)
{
unchecked
{v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; } return v;
}
For the record when I posted this I promise did not realize that previous post was speaking about the exact same thing. How extraordinary is this?
-
This is a little game. Someone in CodeProject wrote this: I'll let you guess what this does and how it should be named:
static int f(int v)
{
unchecked
{v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; } return v;
}
For the record when I posted this I promise did not realize that previous post was speaking about the exact same thing. How extraordinary is this?
Pascal Ganaye wrote:
guess what this does
Checks if Leslie Nielsen is dead or not?
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
-
This is a little game. Someone in CodeProject wrote this: I'll let you guess what this does and how it should be named:
static int f(int v)
{
unchecked
{v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; } return v;
}
For the record when I posted this I promise did not realize that previous post was speaking about the exact same thing. How extraordinary is this?
-
This is a little game. Someone in CodeProject wrote this: I'll let you guess what this does and how it should be named:
static int f(int v)
{
unchecked
{v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; } return v;
}
For the record when I posted this I promise did not realize that previous post was speaking about the exact same thing. How extraordinary is this?
-
I can't really believe it. I found this code in a string library I had downloaded from code project a few days before. I had not read the previous post. What are the odds? This is spooky.