September 1998
Intermediate to advanced
848 pages
20h 13m
English
Convert the following decimal values to binary:
3
13
59
119
Convert the following binary values to decimal, octal, and hexadecimal:
00010101
01010101
01001100
10011101
Evaluate the following expressions; assume each value is 8 bits:
~3
3 & 6
3 | 6
1 | 6
3 ^ 6
7 ≪ 1
7 ≪ 2
Evaluate the following expressions; assume each value is 8 bits:
~0
!0
2 & 4
2 & 4
2 | 4
2 || 4
5 ≪ 3
Because the ASCII code uses only the final 7 bits, sometimes it is desirable to mask off the other bits. What's the appropriate mask in binary? In decimal? In octal? In hexadecimal?
In Listing 15.2, you can replace
while (bits-- > 0)
{
mask |= bitval;
bitval ≪= 1;
}
with
while (bits-- > 0)
{
mask += bitval;
bitval *= 2;
}
and the program still works. Does this mean the operation *=2
Read now
Unlock full access