Chapter 15

I l @ ve RuBoard

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. 1 (true and true is true)

    4. 6

    5. 1 (true or true is true)

    6. 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             : 1;     unsigned int cdromdrives : 2;     unsigned int             : 1;     unsigned int diskdrives  : 2; }; 
I l @ ve RuBoard


C++ Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 314
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net