Here's a much more comprehensive collection of bit hacks: http://graphics.stanford.edu/~seander/bithacks.html
int mask = v >> sizeof(int) * CHAR_BIT - 1;
unsigned int r = (v ^ mask) - mask;
can be granted a patent (http://graphics.stanford.edu/~seander/bithacks.html#IntegerA...).