Q:

What is the value of ~\'q\' << 6 on a machine with 32-bit ints and 8 bit chars, that uses Latin-1 character set in which \'q\' has the bit pattern 01110001

0

What is the value of ~'q' << 6 on a machine with 32-bit ints and 8 bit chars, that uses Latin-1 character set in which 'q' has the bit pattern 01110001?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

`~'q' << 6` is the same as `(~'q') << 6`.

1. The operand of `~` operator is a "small integer"(`char` here), thus its value is first promoted to a larger integral type(`int` here).

    'q' = 01110001 promoted to
               00000000 00000000 00000000 01110001

2. After the `~` operator evaluated,

    ~'q'       11111111 11111111 11111111 10001110

3. Left shift,

    ~'q' << 6  11111111 11111111 11100011 10000000

4. The result is -7296.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now