I'm doing some work with tesseral arithmetic and I need to detect carries in specific areas of a word. Because of the nature of the program, the bits' locations depend on the input. For example, with a 32 bit word size and say, an input of 6 bits, I'd be interested in checking bits 19 and 3 for addition carries and bits 31 and 15 for subtraction (more generally, the interesting bits are (word size - 1), (word size / 2 + input bits / 2), (word size / 2 - 1) and (input bits / 2)).
What I'm thinking is something along the lines of:
(after addition) ((NumberToCheck & (1 << 19 + 1 << 3)) != 0) --> carried bit(s)
(or after subtraction) ((NumberToCheck & (1 << 31 + 1 << 15)) != 0) --> carried bit(s)
Is there a better approach to this?