Chapter 15
00000011
00001101
00111011
01110111
21, 025, 0x15
85, 0125, 0x55
76, 0114, 0x4C
157, 0235, 0x9D
252
2
7
7
5
3
28
255
1 (not false is true)
0
1 (true and true is true)
6
1 (true or true is true)
40
In binary, the mask is 1111111. In decimal, it's 127. In octal, it's 0177. In hexadecimal, it's 0x7F.
Both bitvbal *= 2 and bitval ≪ 1 double the current value of bitval, so they are equivalent. However, mask += bitval and mask |= bitval have the same effect only if bitval and mask have no bits set to on in common. For example, 2 | 4 is 6, but so is 3 | 6.
struct tb_drives { unsigned int diskdrives : 2; unsigned int : 1; unsigned int cdromdrives : 2; unsigned int : 1; unsigned int harddrives : 2; };
struct kb_drives { unsigned int harddrives : 2; unsigned int ...
Get C Primer Plus®, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.