bit twiddling and arbatrary length integers

I was trying to write some preprocessor definitions to handle some useful bitwise operations. They almost worked.
1
2
3
4
5
#define setField(a,b) (a = 0x00 << ( b ) )  // setField(feild, size)
#define flipBit(a,b)  (a = a ^ 0x01 << (b-1) ) // flipBit(field, position)
#define getBit(a,b)   ( (a >> (b-1) & 0x01) ? true : false ) //getBit(field,position)
#define forceOn(a,b)  ( a = a | 0x01 << (b-1) )
//couldn't come up with working forceOff 


during testing I thought they worked. the problem is that every 32 bits it started all over. For instance of I set a field of 1000 bits and forced on bit 1, bits 33,65, and so on would also flip.

First question, I don't see why this happened. Why can I not string together integers like this?
Second, I was working with unsigned int's, shouldn't this have occured every 16 bits?
Third question, obviously I'm wrong about stringing together integers. There has got to be a way I can make an arbatrary length field. I'd prefer to do it without extra libraries.
Such a thing is not possible in c++. There is no 1000 digit number representation. You will either have to write a big integer class with the bitwise operations overloaded or download one.
Topic archived. No new replies allowed.