Hello,

I want to toggle bits in an unsigned long variable. But I get an overflow with bits higher then 31.

Any ideas how to solve this? Thank you.

Code:

unsigned long n = 63;

unsigned long c = 0x8000000000000000;

c ^= (1 << n);

Output:

01111111 | 11111111 | 11111111 | 11111111 | 10000000 | 00000000 | 00000000 | 00000000