Chapter 15

    1. 00000011

    2. 00001101

    3. 00111011

    4. 01110111

    1. 21, 025, 0x15

    2. 85, 0125, 0x55

    3. 76, 0114, 0x4C

    4. 157, 0235, 0x9D

    1. 252

    2. 2

    3. 7

    4. 7

    5. 5

    6. 3

    7. 28

    1. 255

    2. 1 (not false is true)

    3. 0

    4. 1 (true and true is true)

    5. 6

    6. 1 (true or true is true)

    7. 40

  1. In binary, the mask is 1111111. In decimal, it's 127. In octal, it's 0177. In hexadecimal, it's 0x7F.

  2. 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.

    1. struct tb_drives {
          unsigned int diskdrives  : 2;
          unsigned int             : 1;
          unsigned int cdromdrives : 2;
          unsigned int             : 1;
          unsigned int harddrives  : 2;
      };
      
    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.