Originally posted by quzah
Slight correction here on your code:
return !!(number & 1 << bitIndex);
Without the double not statement, you are not actually returning a boolean value. The only way you would, would be if bitIndex was zero. Anything else does not return 1. It returns a power of two.
While it is true that it would work for an equality test, where anything non-zero is considered true, in your case, it is incorrect, because bool should only ever be one or zero.
This would fail:
if( testBit( 2, 1 ) == 1 )
Because "number & 2" would return two, not one.