Hello is it somehow possible to set a bit flag to its real value? example
int a = 0x01 << 7
a = 128
how can I convert the 128 back to 7 ?
I tryed ^= , &= ~, &=
but nothing I did worked.
Hello is it somehow possible to set a bit flag to its real value? example
int a = 0x01 << 7
a = 128
how can I convert the 128 back to 7 ?
I tryed ^= , &= ~, &=
but nothing I did worked.
If you just have a single bit set then you can use a "count trailing zeroes" operation, e.g. using gcc or a gcc-compatible compiler:
int a = 128;
int bit = __builtin_ctz(a); // returns bit = 7