This method was found in C++ production code in the company I work for.
Can you spot the WTF ?
int MyClass::GetTag(int value)
{
int tag = 0;double res = 0;for ( int index = 0; index <= 7; index++ ){if ( (value & 0x1) && (index < 5) )
{
res = pow(2, index);
tag += (int)res;
}
value >>= 1;
}return tag; }
You'll be glad to hear that it has since been fixed, although no one has yet owned up to the original code
:P