struct A { int a:2; int b:3; int c:3; }; int main() { struct A p = {2,6,1}; printf(\"\\n%d\\n%d\\n%d\\n\",p.a,p.b,p.c); return 0; }
Outp
Your system seems to using 2's complement. A 2-bit bit-field holding 2 would be 10 in binary which is -2 in 2's complement system. Likewise 110(6) is -2 for a 3-bit representation in 2's complement. And 1 is plain 1
2-bit
2
10
-2
110(6)
3-bit
1
Also read about signed bit-fields here