We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3538007 commit 640cd97Copy full SHA for 640cd97
c/BitField/main.c
@@ -0,0 +1,19 @@
1
+#include <stdio.h>
2
+int main()
3
+{
4
+ struct BitField
5
+ {
6
+ unsigned int a : 3;
7
+ int b : 2;
8
+ unsigned int c : 1;
9
+ };
10
+ struct BitField bitfield;
11
+ bitfield.a = 125; // bitfield.a = x -> while(bitfield.a is not in the range) -> bitfield.a = num +- (2^3)
12
+ bitfield.b = -5; // bitfield.b = x -> while(bitfield.b is not in the range) -> bitfield.b = num +- (2^2)
13
+ bitfield.c = -1;
14
+ printf("%d\n%d\n%d\n", bitfield.a, bitfield.b, bitfield.c);
15
+ printf("sizeof(struct BitField) is %llu\n", sizeof(struct BitField));
16
+
17
+ printf("125%(2^3)=%d\n", 125 % (1 << 3));
18
+ printf("(-5)%(2^2)=%d\n", -5 % (1 << 2));
19
+}
0 commit comments